-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbackground.js
130 lines (128 loc) · 3.75 KB
/
background.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/*
github.com/n0nexist/AdSmack
*/
// List of regex patterns to block
const BLOCKED_URLS = [
"*://*.doubleclick.net/*",
"*://partner.googleadservices.com/*",
"*://adservice.google.com/*",
"*://*.googlesyndication.com/*",
"*://*.google-analytics.com/*",
"*://creative.ak.fbcdn.net/*",
"*://*.adbrite.com/*",
"*://*.exponential.com/*",
"*://*.quantserve.com/*",
"*://*.scorecardresearch.com/*",
"*://*.zedo.com/*",
"*://*.adblade.com/*",
"*://*.adclickmedia.com/*",
"*://*.adnxs.com/*",
"*://*.adroll.com/*",
"*://*.adserver.com/*",
"*://*.adtech.com/*",
"*://*.atdmt.com/*",
"*://*.casalemedia.com/*",
"*://*.chitika.com/*",
"*://*.clicksor.com/*",
"*://*.criteo.com/*",
"*://*.districtm.net/*",
"*://*.dynamicyield.com/*",
"*://*.engagebdr.com/*",
"*://*.fastclick.com/*",
"*://*.flashtalking.com/*",
"*://*.gemini.yahoo.com/*",
"*://*.imrworldwide.com/*",
"*://*.infolinks.com/*",
"*://*.intellimize.com/*",
"*://*.jsdelivr.net/*",
"*://*.krxd.net/*",
"*://*.liveintent.com/*",
"*://*.maxmind.com/*",
"*://*.media.net/*",
"*://*.mediaplex.com/*",
"*://*.mgid.com/*",
"*://*.moatads.com/*",
"*://*.monetate.net/*",
"*://*.nativeads.com/*",
"*://*.ooyala.com/*",
"*://*.outbrain.com/*",
"*://*.perimeterx.net/*",
"*://*.pixel.adsafeprotected.com/*",
"*://*.pubmatic.com/*",
"*://*.quantummetric.com/*",
"*://*.redditads.com/*",
"*://*.revcontent.com/*",
"*://*.rubiconproject.com/*",
"*://*.sharethrough.com/*",
"*://*.simpli.fi/*",
"*://*.smartadserver.com/*",
"*://*.taboola.com/*",
"*://*.tapad.com/*",
"*://*.teads.tv/*",
"*://*.hotjar.*/*",
"*://*events.hotjar.io/*",
"*://*.ads-twitter.com/*",
"*://*analytics.twitter.com/*",
"*://*ads.twitter.com/*",
"*://*ads-api.twitter.com/*",
"*://*s3.amazonaws.com/*",
"*://*advertising*amazonaws.com/*",
"*://*.adcolony.com/*",
"*://app-measurement.com/*",
"*://analytics.google.com/*",
"*://*.googleanalytics.com/*",
"*://*.freshmarketer.com/*",
"*://*freshmarketer.com/*",
"*://stats.wp.com/*",
"*://*.luckyorange.*/*",
"*://luckyorange.com/*",
"*://*.sentry-cdn.*/*",
"*://*.bugsnag.*/*",
"*://pixel.facebook.com/*",
"*://an.luckyorange.com/*",
"*://*.redditmedia.com/*",
"*://events.reddit.com/*",
"*://ads-api.tiktok.*/*",
"*://analytics.tiktok.*/*",
"*://analytics-sg.tiktok.*/*",
"*://business-api.tiktok.*/*",
"*://ads.tiktok.*/*",
"*://ads.youtube.com/*",
"*://ads.pinterest.*/*",
"*://log.pinterest.*/*",
"*://analytics.pinterest.*/*",
"*://trk.pinterest.*/*",
"*://widgets.pinterest.*/*",
"*://ads.yahoo.*/*",
"*://geo.yahoo.*/*",
"*://udc.yahoo.*/*",
"*://udcm.yahoo.*/*",
"*://analytics.query.yahoo.*/*",
"*://partnerads.ysm.yahoo.*/*",
"*://log.fc.yahoo.*/*",
"*://gemini.yahoo.*/*",
"*://adtech.yahoo.*/*",
"*://extmaps-api.yandex.*/*",
"*://appmetrica.yandex.*/*",
"*://adfstat.yandex.*/*",
"*://metrika.yandex.*/*",
"*://advertising.yandex.*/*",
"*://offerwall.yandex.*/*",
"*://*.unityads.unity3d.com/*",
];
// Short adblock script
browser.webRequest.onBeforeRequest.addListener(
function(details) {
// Check if the request URL matches any of the blocked patterns
// Using regular expressions
for (let pattern of BLOCKED_URLS) {
let regex = new RegExp(pattern.replace(/\*/g, '.*'));
if (regex.test(details.url)) {
// Drops the request
return {cancel: true};
}
}
},
{urls: ["<all_urls>"]}, // Make this work on all urls
["blocking"]
);