1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | 'use strict';
|
18 |
|
19 | const puppeteer = require('puppeteer');
|
20 |
|
21 | function sniffDetector() {
|
22 | const userAgent = window.navigator.userAgent;
|
23 | const platform = window.navigator.platform;
|
24 |
|
25 | window.navigator.__defineGetter__('userAgent', function() {
|
26 | window.navigator.sniffed = true;
|
27 | return userAgent;
|
28 | });
|
29 |
|
30 | window.navigator.__defineGetter__('platform', function() {
|
31 | window.navigator.sniffed = true;
|
32 | return platform;
|
33 | });
|
34 | }
|
35 |
|
36 | (async() => {
|
37 | const browser = await puppeteer.launch();
|
38 | const page = await browser.newPage();
|
39 | await page.evaluateOnNewDocument(sniffDetector);
|
40 | await page.goto('https://www.google.com', {waitUntil: 'networkidle2'});
|
41 | console.log('Sniffed: ' + (await page.evaluate(() => !!navigator.sniffed)));
|
42 |
|
43 | await browser.close();
|
44 | })();
|