-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontentScript.js
More file actions
43 lines (38 loc) · 1.02 KB
/
contentScript.js
File metadata and controls
43 lines (38 loc) · 1.02 KB
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
console.log("Executing Sindy's ufret plugin");
var SHEET_ID = "my-chord-data"
var CHORD_CLASS = "krijcheug"
var LYRIC_CLASS = "mejiowvnz"
function isNodeToKeep(node) {
return (node.localName === "style"
&& node.innerHTML.includes("musical-sheet"));
}
function removeAllSiblings(node) {
var parent = node.parentNode;
var curr = node;
while (curr.previousSibling) {
if (isNodeToKeep(curr.previousSibling)) {
curr = curr.previousSibling;
} else {
parent.removeChild(curr.previousSibling);
}
}
curr = node;
while (curr.nextSibling) {
if (isNodeToKeep(curr.nextSibling)) {
curr = curr.nextSibling;
} else {
parent.removeChild(curr.nextSibling);
}
}
}
function removeAllAncestorsSiblings(node) {
var curr = node.parentNode;
while (curr.parentNode.localName !== "html") {
removeAllSiblings(curr);
curr = curr.parentNode;
}
}
var sheet = document.getElementById(SHEET_ID);
removeAllAncestorsSiblings(sheet);
removeAllSiblings(sheet);
sheet.style['column-count'] = 3;