-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathdir-string.js
59 lines (54 loc) · 1.51 KB
/
dir-string.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
import { hit } from '../helpers';
/* eslint-disable max-len */
/**
* @scriptlet dir-string
*
* @description
* Wraps the `console.dir` API to call the `toString` method of the argument.
* There are several adblock circumvention systems that detect browser devtools
* and hide themselves. Therefore, if we force them to think
* that devtools are open (using this scriptlet),
* it will automatically disable the adblock circumvention script.
*
* ### Syntax
*
* ```text
* example.org#%#//scriptlet('dir-string'[, times])
* ```
*
* - `times` — optional, the number of times to call the `toString` method of the argument to `console.dir`
*
* ### Examples
*
* ```adblock
* ! Run 2 times
* example.org#%#//scriptlet('dir-string', '2')
* ```
*
* @added v1.0.4.
*/
/* eslint-enable max-len */
export function dirString(source, times) {
const { dir } = console;
times = parseInt(times, 10);
function dirWrapper(object) {
// eslint-disable-next-line no-unused-vars
let temp;
for (let i = 0; i < times; i += 1) {
// eslint-disable-next-line no-unused-expressions
temp = `${object}`;
}
if (typeof dir === 'function') {
dir.call(this, object);
}
hit(source, temp);
}
// eslint-disable-next-line no-console
console.dir = dirWrapper;
}
export const dirStringNames = [
'dir-string',
];
// eslint-disable-next-line prefer-destructuring
dirString.primaryName = dirStringNames[0];
dirString.injections = [hit];