-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnano-adblocker.js
390 lines (375 loc) · 10.9 KB
/
nano-adblocker.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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
# Expires: 3 days
# License: See source for license and credits
# Source: https://github.com/NanoAdblocker/NanoFilters/tree/master/NanoFiltersSource/NanoResources.txt
# This file is a compiled binary, do not modify
# All modifications will be overwritten on the next build
nano-tiny-noopvast-2.0 text/xml
<VAST version="2.0"></VAST>
nano-tiny-noopvast-3.0 text/xml
<VAST version="3.0"></VAST>
nano-assign-variable-onready.js application/javascript
(function() {
var chain = '{{1}}';
var value = '{{2}}';
if ( chain === '' || chain === '{{1}}' ) {
return;
}
if ( value === 'null' ) {
value = null;
} else if ( value === 'true' ) {
value = true;
} else if ( value === 'false' ) {
value = false;
} else {
return;
}
var assign = function() {
var parent = window;
chain = chain.split('.');
for ( var i = 0; i < chain.length - 1; i++ ) {
parent = parent[chain[i]];
}
parent[chain[chain.length - 1]] = value;
};
if ( document.readyState === 'interactive' ||
document.readyState === 'complete' ) {
assign();
} else {
addEventListener('DOMContentLoaded', assign);
}
})();
nano-vvvvid-it.js application/javascript
(function() {
// Based on KAADIVVVV
// License: https://github.com/Robotex/KAADIVVVV/blob/master/LICENSE
function defuse() {
var checkAdv = function() {
this.hasAdv = false;
};
vvvvid.models.PlayerObj.prototype.checkAdv = checkAdv;
window[wnbshgd] = vvvvid.models.PlayerObj.prototype.checkAdv;
}
if ( typeof vvvvid === 'object' ) {
defuse();
} else {
addEventListener('DOMContentLoaded', defuse);
}
})();
nano-colombiaonline-com.js application/javascript
(function() {
var magic = 'a' + Math.random().toString(36).substring(2);
var testScript = "typeof otab == 'function'";
var testComment = /\d{5,} \d{1,2}/;
//
var getter = function() {
var script, temp;
//
temp = Array.from(document.querySelectorAll(
'script:not([src]):not([' + magic + '])'
));
if (
document.currentScript &&
!document.currentScript.hasAttribute(magic)
) {
temp.unshift(document.currentScript);
}
if ( temp.length === 0 ) {
return true;
}
for ( var e of temp ) {
e.setAttribute(magic, '');
if ( e.textContent && e.textContent.includes(testScript) ) {
script = e;
break;
}
}
//
if ( script === undefined ) {
return true;
}
var prev = script.previousSibling;
temp = prev;
while ( temp = temp.previousSibling ) {
if (
temp.nodeType === Node.COMMENT_NODE &&
testComment.test(temp.data)
) {
prev.style.setProperty('display', 'none', 'important');
return false;
}
}
};
//
Object.defineProperty(window, "trev", {
set: function() { },
get: function() {
var r;
var i = 0;
do {
try {
r = getter();
} catch ( err ) { }
} while ( i++, !r && i < 100 );
return null;
}
});
addEventListener('load', function() {
void trev;
});
//
var isInBackground = false;
var reStart = /^\/[a-z_]+\.cms/;
var reEnd = /^ \d{5,} \d{1,2} $/;
var adsHidder = function() {
if ( isInBackground || !document.body ) {
return;
}
var iterator = document.createTreeWalker(
document.body, NodeFilter.SHOW_COMMENT
);
var comment;
while ( comment = iterator.nextNode() ) {
if ( reStart.test(comment.data) ) {
var toHide = [];
var prev = comment;
while ( prev = prev.previousSibling ) {
if (
prev.nodeType === Node.COMMENT_NODE &&
reEnd.test(prev.data)
) {
if ( toHide.length < 15 ) {
for ( var e of toHide ) {
try {
e.style.setProperty(
'display', 'none', 'important'
);
} catch ( err ) { }
}
}
break;
}
toHide.push(prev);
}
}
}
};
addEventListener('focus', function() {
isInBackground = false;
});
addEventListener('blur', function() {
isInBackground = true;
});
setInterval(adsHidder, 1000);
})();
nano-hijack-script-create.js application/javascript
(function() {
var _createElement = document.createElement;
var needle = '{{1}}';
if ( needle === '' || needle === '{{1}}' ) {
needle = '.?';
} else if ( needle.length > 2 &&
needle.startsWith('/') && needle.endsWith('/') ) {
needle = needle.slice(1,-1);
} else {
needle = needle.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
}
needle = new RegExp(needle);
document.createElement = function(name) {
var elem = _createElement.apply(this, arguments);
if ( name === 'script' ) {
elem.addEventListener('error', function(e) {
if ( needle.test(elem.src) ) {
e.preventDefault();
e.stopPropagation();
var ev = new Event('load');
elem.dispatchEvent(ev);
}
});
}
return elem;
};
})();
nano-remove-elements-onready.js application/javascript
(function() {
var selector = '{{1}}';
if ( selector === '' || selector === '{{1}}' ) {
return;
}
var remove = function() {
var elements = document.querySelectorAll(selector);
for ( var element of elements ) {
element.remove();
}
};
if ( document.readyState === 'interactive' ||
document.readyState === 'complete' ) {
remove();
} else {
addEventListener('DOMContentLoaded', remove);
}
})();
nano-make-bait-element.js application/javascript
(function() {
var identifier = '{{1}}';
var element = document.createElement('div');
if ( identifier.charAt(0) === '#' ) {
element.id = identifier.substring(1);
} else if ( identifier.charAt(0) === '.' ) {
element.className = identifier.substring(1);
} else {
return;
}
element.style.display = 'none';
document.documentElement.appendChild(element);
})();
nano-grant-fake-notification.js application/javascript
(function() {
Notification = function() { };
Notification.permission = 'default';
Notification.requestPermission = function(callback) {
Notification.permission = 'granted';
if ( callback ) {
setTimeout(callback, 0, 'granted');
}
return Promise.resolve('granted');
};
})();
nano-abort-inline-scripts-by-id.js application/javascript
(() => {
let needle = '{{1}}';
if (needle === '' || needle === '{{1}}') {
return;
} else if (needle.startsWith('/') && needle.endsWith('/')) {
needle = needle.slice(1, -1);
} else {
needle = '^' + needle.replace(/[.*+?^${}()|[\]\\]/g, '\\$&') + '$';
}
needle = new RegExp(needle);
//
const observer = new MutationObserver((mutations) => {
for (const mutation of mutations) {
for (const node of mutation.addedNodes) {
if (node.tagName === 'SCRIPT' && needle.test(node.id)) {
node.textContent = '';
node.remove();
}
}
}
});
if (document.readyState === 'interactive' ||
document.readyState === 'complete') {
return; // Too late
} else {
observer.observe(document, {
childList: true,
subtree: true,
});
addEventListener('DOMContentLoaded', () => {
observer.disconnect();
});
}
})();
nanop-click-elements-onready.js application/javascript
(function() {
var guard = '{{nano}}';
if ( guard === '{{nano}}' ) {
return;
}
var selector = '{{1}}';
if ( selector === '' || selector === '{{1}}' ) {
return;
}
var click = function() {
var elements = document.querySelectorAll(selector);
for ( var element of elements ) {
element.click();
}
};
if ( document.readyState === 'interactive' ||
document.readyState === 'complete' ) {
click();
} else {
addEventListener('DOMContentLoaded', click);
}
})();
nanop-click-elements-onload.js application/javascript
(function() {
var guard = '{{nano}}';
if ( guard === '{{nano}}' ) {
return;
}
var selector = '{{1}}';
if ( selector === '' || selector === '{{1}}' ) {
return;
}
var click = function() {
var elements = document.querySelectorAll(selector);
for ( var element of elements ) {
element.click();
}
};
if ( document.readyState === 'complete' ) {
click();
} else {
addEventListener('load', click);
}
})();
nanop-easy-set-cookie.js application/javascript
(function() {
var guard = '{{nano}}';
if ( guard === '{{nano}}' ) {
return;
}
var data = '{{1}}';
var path = '{{2}}';
var domain = '{{3}}';
var secure = '{{4}}';
var del = '{{5}}';
if ( data.indexOf('=') === -1 ) {
return;
}
if ( del === 'true' ) {
data += ';max-age=-100';
} else {
data += ';max-age=2592000'; // 30 days
}
if ( path !== '' && path !== '{{2}}' ) {
data += ';path=' + path;
}
if ( domain !== '' && domain !== '{{3}}' ) {
data += ';domain=' + domain;
}
if ( secure === 'true' ) {
data += ';secure';
}
document.cookie = data;
})();
nanop-set-cookie.js application/javascript
(function() {
var guard = '{{nano}}';
if ( guard === '{{nano}}' ) {
return;
}
var data = '{{1}}';
if ( data.indexOf('=') === -1 ) {
return;
}
document.cookie = data;
})();
nanop-get-redirect.js application/javascript
(() => {
var guard = '{{nano}}';
if ( guard === '{{nano}}' ) {
return;
}
var data = '{{1}}';
if ( data === '' || data === '{{1}}' ) {
return;
}
var url = new URL(location.href);
var param = url.searchParams.get(data);
if ( typeof param !== 'string' || !/^https?:\/\//.test(param) ) {
return;
}
location.href = param;
})();