-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhide-script.js
68 lines (58 loc) · 1.51 KB
/
hide-script.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
60
61
62
63
64
65
66
67
68
const hideText = "Show";
const hideColor = "#455a64";
function handleDifficultyTag(node) {
const initialText = node.innerText;
const initialColor = node.style.color;
const initialBackgroundColor = node.style["background-color"];
function revealTag() {
node.innerText = initialText;
node.style.color = initialColor;
node.style["background-color"] = initialBackgroundColor;
}
function hideTag() {
node.innerText = hideText;
node.style.color = hideColor;
node.style["background-color"] = "#ffffff";
}
hideTag();
node.addEventListener("click", () => {
if (node.innerText == initialText) {
hideTag();
} else {
revealTag();
}
});
}
if (document.readyState === "loading") {
document.addEventListener("DOMContentLoaded", afterDOMLoaded);
} else {
afterDOMLoaded();
}
function afterDOMLoaded() {
//Everything that needs to happen after the DOM has initially loaded.
const easyTag = document.evaluate(
"//div[text()='Easy']",
document,
null,
XPathResult.FIRST_ORDERED_NODE_TYPE,
null
).singleNodeValue;
const mediumTag = document.evaluate(
"//div[text()='Medium']",
document,
null,
XPathResult.FIRST_ORDERED_NODE_TYPE,
null
).singleNodeValue;
const hardTag = document.evaluate(
"//div[text()='Hard']",
document,
null,
XPathResult.FIRST_ORDERED_NODE_TYPE,
null
).singleNodeValue;
const difficultyTag = easyTag || mediumTag || hardTag;
if (difficultyTag) {
handleDifficultyTag(difficultyTag);
}
}