-
Notifications
You must be signed in to change notification settings - Fork 0
/
gaana.js
54 lines (49 loc) · 1.97 KB
/
gaana.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
let muted = false;
let nowPlayingBarObserver = new MutationObserver(mutations => {
for (let mutation of mutations) {
if (mutation.attributeName === "style") {
const nowPlayingBar = document.querySelector("#mq_ads");
const volumeRocker = document.querySelector("#muteBtn");
if (nowPlayingBar.getAttribute("style") !== "display: none;") {
console.log("ad is playing");
if (!muted) {
volumeRocker?.click();
}
} else {
if (muted) {
volumeRocker?.click();
}
}
}
}
});
let muteButtonObserver = new MutationObserver(mutations => {
for (let mutation of mutations) {
if (mutation.attributeName === "class") {
const volumeRocketLabel = document.querySelector("#muteBtn")?.classList;
if (!volumeRocketLabel.contains("muteAds")) {
muted = false;
} else {
muted = true;
}
}
}
});
let nowPlayingBarRenderingObserver = new MutationObserver(mutations => {
for (let mutation of mutations) {
if (document.querySelector("#mq_ads")) {
nowPlayingBarObserver.observe(document.querySelector("#mq_ads"), { childList: true, subtree: true, attributes: true });
nowPlayingBarRenderingObserver.disconnect();
}
}
});
let muteButtonRenderingObserver = new MutationObserver(mutations => {
for (let mutation of mutations) {
if (document.querySelector("#muteBtn")) {
muteButtonObserver.observe(document.querySelector("#muteBtn"), { childList: true, subtree: true, attributes: true });
muteButtonRenderingObserver.disconnect();
}
}
});
nowPlayingBarRenderingObserver.observe(document, { childList: true, subtree: true, attributes: true });
muteButtonRenderingObserver.observe(document, { childList: true, subtree: true, attributes: true });