-
Notifications
You must be signed in to change notification settings - Fork 2
/
hlcheck_bypass.go
40 lines (33 loc) · 1.09 KB
/
hlcheck_bypass.go
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
package chromedl
// Headless check bypass
// https://github.com/chromedp/chromedp/issues/396
const script = `(function(w, n, wn) {
// Pass the Webdriver Test.
Object.defineProperty(n, 'webdriver', {
get: () => false,
});
// Pass the Plugins Length Test.
// Overwrite the plugins property to use a custom getter.
Object.defineProperty(n, 'plugins', {
// This just needs to have length > 0 for the current test,
// but we could mock the plugins too if necessary.
get: () => [1, 2, 3, 4, 5],
});
// Pass the Languages Test.
// Overwrite the plugins property to use a custom getter.
Object.defineProperty(n, 'languages', {
get: () => ['en-US', 'en'],
});
// Pass the Chrome Test.
// We can mock this in as much depth as we need for the test.
w.chrome = {
runtime: {},
};
// Pass the Permissions Test.
const originalQuery = wn.permissions.query;
return wn.permissions.query = (parameters) => (
parameters.name === 'notifications' ?
Promise.resolve({ state: Notification.permission }) :
originalQuery(parameters)
);
})(window, navigator, window.navigator);`