-
Notifications
You must be signed in to change notification settings - Fork 29
/
prevent-bab2.js
56 lines (50 loc) · 1.25 KB
/
prevent-bab2.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
/* eslint-disable consistent-return, no-eval */
import { hit } from '../helpers/index';
/**
* @redirect prevent-bab2
*
* @description
* Prevents BlockAdblock script from detecting an ad blocker.
*
* Related UBO redirect:
* https://github.com/gorhill/uBlock/blob/master/src/web_accessible_resources/nobab2.js
*
* See [redirect description](../wiki/about-redirects.md#prevent-bab2).
*
* ### Examples
*
* ```adblock
* /blockadblock.$script,redirect=prevent-bab2
* ```
*
* @added v1.5.0.
*/
export function preventBab2(source) {
const script = document.currentScript;
if (script === null) {
return;
}
const url = script.src;
if (typeof url !== 'string') {
return;
}
const domainsStr = [
'adclixx\\.net',
'adnetasia\\.com',
'adtrackers\\.net',
'bannertrack\\.net',
].join('|');
const matchStr = `^https?://[\\w-]+\\.(${domainsStr})/.`;
const domainsRegex = new RegExp(matchStr);
if (domainsRegex.test(url) === false) {
return;
}
window.nH7eXzOsG = 858;
hit(source);
}
preventBab2.names = [
'prevent-bab2',
// aliases are needed for matching the related scriptlet converted into our syntax
'nobab2.js',
];
preventBab2.injections = [hit];