-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
45 lines (40 loc) · 1.4 KB
/
index.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
// configuration of the observers
var config = { attributes: true, childList: true, characterData: true };
// select the ads node (ads container)
const ads = document.querySelector("[data-role='toast-container']");
let goPro;
window.onload = function () {
goPro = document.getElementById("overlap-manager-root");
observerGoPro.observe(goPro, config);
};
// create an observer instance for ads
var observer = new MutationObserver(function (mutations) {
mutations.forEach(function (mutation) {
if (mutation.type == "childList") {
if (mutation.addedNodes.length >= 1) {
for (var i = 0; i < mutation.addedNodes.length; i++) {
// remove ads when it appears
ads.removeChild(mutation.addedNodes[i]);
console.log("Ad removed!");
}
}
}
});
});
// create an observer instance for "Go Pro" ad
var observerGoPro = new MutationObserver(function (mutations) {
mutations.forEach(function (mutation) {
if (mutation.type == "childList") {
if (mutation.addedNodes.length >= 1) {
for (var i = 0; i < mutation.addedNodes.length; i++) {
if (mutation.addedNodes[0].nextElementSibling) {
mutation.addedNodes[0].nextElementSibling.childNodes[0].remove();
console.log("Go Pro ad removed!");
}
}
}
}
});
});
// pass in the ads node, as well as the observer options
observer.observe(ads, config);