-
Notifications
You must be signed in to change notification settings - Fork 0
/
headless.js
41 lines (34 loc) · 957 Bytes
/
headless.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
/* 注入灵魂 */
/* 干掉 webdriver */
Object.defineProperty(navigator, 'webdriver', {
get: () => false,
configurable: true,
writable: true,
});
Reflect.deleteProperty(navigator, 'webdriver')
/* 干掉 navigator.chrome */
Object.defineProperty(navigator, 'chrome', {
get: () => undefined,
configurable: true,
writable: true,
});
Reflect.deleteProperty(window, 'chrome')
// 添加 window.chrome
window.navigator.chrome = {
runtime: {},
};
/* 干掉 permissions */
const originalQuery = window.navigator.permissions.query;
return window.navigator.permissions.query = (parameters) => (
parameters.name === 'notifications' ?
Promise.resolve({ state: Notification.permission }) :
originalQuery(parameters)
);
/* 干提 navigator.plugins */
Object.defineProperty(navigator, 'plugins', {
get: () => [1, 2, 3, 4, 5],
});
/* 干掉 languages */
Object.defineProperty(navigator, 'languages', {
get: () => ['zh-CN', 'zh'],
});