-
Notifications
You must be signed in to change notification settings - Fork 4
/
DBS+.user.js
59 lines (58 loc) · 2.08 KB
/
DBS+.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// ==UserScript==
// @name DBS+
// @namespace https://deadbeefsociety.org
// @version 0.0.4
// @description Make DBS better
// @author somebody
// @match *://deadbeefsociety.org
// @match *://deadbeefsociety.org/*
// @match *://*.deadbeefsociety.org
// @match *://*.deadbeefsociety.org/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
let url = window.location.href;
if (/scoreboard.deadbeefsociety.org\/?$/.test(url)) {
let style = document.createElement('style');
style.innerHTML = `\
.levelstats-cell:hover {
background-color: #bbbbbb;
cursor: pointer;
}`;
document.head.appendChild(style);
let observer = new MutationObserver(function (records) {
for (let record of records)
if (record.type === 'childList')
for (let node of record.addedNodes)
for (let child of node.childNodes)
if (
child.classList.contains('levelstats-cell') &&
!/^ level 0x[0-9a-f]{2}$/.test(child.innerText) &&
!/^ total cleared: \d+$/.test(child.innerText)
)
child.addEventListener('click', () => window.location.href = 'https://scoreboard.deadbeefsociety.org/view/' + child.innerText);
});
observer.observe(document.getElementById('levelstats'), { childList: true });
} else if (/scoreboard.deadbeefsociety.org\/leaderboard\/?$/.test(url)) {
let style = document.createElement('style');
style.innerHTML = `\
.large-offset-2.leader:hover {
background-color: #bbbbbb;
cursor: pointer;
}
.board.level:hover {
background-color: #444444;
}`;
document.head.appendChild(style);
for (let node of [].slice.call(document.getElementsByClassName('large-offset-2'), 1))
node.addEventListener('click', () => window.location.href = 'https://scoreboard.deadbeefsociety.org/view/' + node.innerText);
} else {
let style = document.createElement('style');
style.innerHTML = `\
.board.level:hover {
background-color: #444444;
}`;
document.head.appendChild(style);
}
})();