justart
/**
 * Copyright 2017 Google Inc., PhantomJS Authors All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

\'use strict\';

const puppeteer = require(\'puppeteer\');

function sniffDetector() {
  const userAgent = window.navigator.userAgent;
  const platform = window.navigator.platform;

  window.navigator.__defineGetter__(\'userAgent\', function() {
    window.navigator.sniffed = true;
    return userAgent;
  });

  window.navigator.__defineGetter__(\'platform\', function() {
    window.navigator.sniffed = true;
    return platform;
  });
}

(async() => {
  const browser = await puppeteer.launch();
  const page = await browser.newPage();
  await page.evaluateOnNewDocument(sniffDetector);
  await page.goto(\'https://www.google.com\', {waitUntil: \'networkidle2\'});
  console.log(\'Sniffed: \' + (await page.evaluate(() => !!navigator.sniffed)));

  await browser.close();
})();

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2022-01-01
  • 2021-06-16
  • 2021-12-20
  • 2022-01-09
  • 2021-11-17
  • 2021-10-31
  • 2021-10-10
猜你喜欢
  • 1970-01-01
  • 2021-12-22
  • 2021-08-18
  • 2021-12-17
  • 2021-05-23
  • 2021-07-11
  • 2022-12-23
相关资源
相似解决方案