-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontent.js
82 lines (79 loc) · 1.97 KB
/
content.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
async function removeAds() {
var elementsToHide = [];
elementsToHide = [
'[class*="adswarning"]',
'[class*="ad300"]',
'[class*="adHeight"]',
'[class*="special-offer"]',
'[id*="adslot"]',
'[class*="rightAd"]',
'[id*="gpt-ad"]',
'[class*="ad-slot"]',
'[class*="ad-container"]',
'[aria-label*="advertisement"]',
'[class*="adnative"]',
'[class*=".wps-player__happy-inside"]',
'[id*="admobile"]',
'[id*="deskad"]',
".vjs-inplayer-container",
"#movieplayer-box-adv",
"#EPimLayerOuter",
'[class*="ads-banner"]',
'[class*="ad-box"]',
'[id*="adframe"]',
'[class*="promo-ad"]',
'[id*="adleaderboard"]',
'[class*="banner-ad"]',
'[id*="sponsored"]',
'[class*="ad-display"]',
'[id*="advert"]',
'[class*="popup-ad"]',
'[id*="adside"]',
'[class*="adspace"]',
'[class*="adblock"]',
'[id*="adtop"]',
".ad-wrapper",
".advertisement-container",
".ad-section",
'[class*="ad-wrap"]',
'[class*="ad-banner"]',
'[id*="adcontainer"]',
'[class*="adsense"]',
'[id*="ads_bottom"]',
'[class*="ad-section"]',
'[class*="adsbox"]',
'[class*="ad-unit"]',
'[class*="inline-ad"]',
'[id*="ad-sidebar"]',
'[class*="advert-unit"]',
'[id*="adblocker"]',
'[class*="ad-overlay"]',
'[id*="adblock-sidebar"]',
'[class*="sponsored-content"]',
'[class*="ad-vertical"]',
".sponsored-post",
"#ad-footer",
"#ad-header",
".ad-background",
".video-archive-ad",
"#topAdv",
".sidebar-ads",
];
elementsToHide.forEach((selector) => {
document.querySelectorAll(selector).forEach((element) => element.remove());
});
}
function monitorAds() {
const isYT = window.location.hostname.includes("youtube.com");
if (isYT) {
ytBlocker();
} else {
const observer = new MutationObserver(removeAds);
observer.observe(document.body, {
childList: true,
subtree: true,
});
}
}
removeAds();
monitorAds();