-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontent-script.js
More file actions
47 lines (39 loc) · 1013 Bytes
/
Copy pathcontent-script.js
File metadata and controls
47 lines (39 loc) · 1013 Bytes
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
console.log("BBB identified")
var observer = new MutationObserver(function (mutations) {
if (
getElementByXpath(
"/html/body/div/main/section/div[1]/section[2]/div/div[2]"
) != null
) {
var menuBarDiv = getElementByXpath(
"/html/body/div/main/section/div[1]/section[2]/div/div[2]"
);
injectVolumeSlider(menuBarDiv);
observer.disconnect();
}
});
observer.observe(document.body, {
childList: true,
subtree: true,
});
function injectVolumeSlider(target) {
var slider = document.createElement("INPUT");
slider.min = 0;
slider.max = 100;
slider.value = 100;
slider.type = "range";
target.appendChild(slider);
slider.addEventListener("input", function () {
document.querySelector("audio").volume = slider.value / 100;
console.log("Set volume to: " + slider.value);
});
}
function getElementByXpath(path) {
return document.evaluate(
path,
document,
null,
XPathResult.FIRST_ORDERED_NODE_TYPE,
null
).singleNodeValue;
}