This repository has been archived by the owner on Oct 15, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 28
/
NanoResources.txt
471 lines (424 loc) · 13.6 KB
/
NanoResources.txt
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
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
# ---------------------------------------------------------------------------- #
# Extra resources for Nano Adblocker
# Same format as uBlock Origin's resources file
# Everything should be prefixed with "nano-" to prevent name collision
# However, collided names will always cause uBlock Origin's resources to be
# overridden, and can be done purposefully when intervention is required
# This file is no longer in use, the new file is located at:
# https://github.com/NanoAdblocker/NanoCore2/blob/master/src/snippets.js
# ---------------------------------------------------------------------------- #
nano-tiny-noopvast-2.0 text/xml
<VAST version="2.0"></VAST>
nano-tiny-noopvast-3.0 text/xml
<VAST version="3.0"></VAST>
# Assign a variable when the document gets ready, 2 required arguments.
# chain - The property chain.
# value - The value to assign, must be 'null', 'true', or 'false'.
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);
}
})();
# ---------------------------------------------------------------------------- #
# Specific resources
# Nothing for now...
# ---------------------------------------------------------------------------- #
# Experimental resources, these can change or break at any time
# https://github.com/jspenguin2017/uBlockProtector/issues/390
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);
}
})();
# https://github.com/uBlockOrigin/uAssets/issues/247
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);
})();
# Patch document.createElement and prevent created script from receiving
# network error event, 1 required argument
# url - The URL matcher of the script
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;
};
})();
# Remove elements when the document gets ready, 1 required argument.
# selector - The selector for elements to remove, must be a plain CSS selector,
# pseudo-selectors are not supported.
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);
}
})();
# Insert an invisible elements onto the page, can be used to dodge baits,
# 1 required argument.
# identifier - An identifier, either an id or a class name. Like "#id" or
# ".class"
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);
})();
# Grant fake notification permission
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');
};
})();
# Prevent inline scripts with specific IDs from executing, 1 required argument
# needle - The ID matcher, can be a plain string (exact match) or a regular
# expression
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();
});
}
})();
# ---------------------------------------------------------------------------- #
# Privileged resources, these are only available to Nano Adblocker's trusted
# filter lists
# Click elements when the document gets ready, 1 required argument.
# selector - The selector for elements to remove, must be a plain CSS selector,
# pseudo-selectors are not supported.
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);
}
})();
# Click elements when the document gets loaded, 1 required argument.
# selector - The selector for elements to remove, must be a plain CSS selector,
# pseudo-selectors are not supported.
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);
}
})();
# Set a cookie, 1 required arguments, 3 optional arguments.
# data - The key=value pair.
# path - Optional, the path, default to current path.
# domain - Optional, the domain, default to current domain.
# secure - true or false. Optional, default to false.
# del - true or false. Set to true to delete the cookie instead. Optional,
# default to false.
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;
})();
# Set a cookie the hard way, 1 required argument.
# data - The cookie data to set.
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;
})();
# Redirect to a URL in GET parameter
# key - The parameter key
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;
})();
# ---------------------------------------------------------------------------- #