Rename to hkt.sh
This commit is contained in:
49
node_modules/puppeteer-extra-plugin-stealth/evasions/navigator.hardwareConcurrency/index.js
generated
vendored
Normal file
49
node_modules/puppeteer-extra-plugin-stealth/evasions/navigator.hardwareConcurrency/index.js
generated
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
'use strict'
|
||||
|
||||
const { PuppeteerExtraPlugin } = require('puppeteer-extra-plugin')
|
||||
|
||||
const withUtils = require('../_utils/withUtils')
|
||||
|
||||
/**
|
||||
* Set the hardwareConcurrency to 4 (optionally configurable with `hardwareConcurrency`)
|
||||
*
|
||||
* @see https://arh.antoinevastel.com/reports/stats/osName_hardwareConcurrency_report.html
|
||||
*
|
||||
* @param {Object} [opts] - Options
|
||||
* @param {number} [opts.hardwareConcurrency] - The value to use in `navigator.hardwareConcurrency` (default: `4`)
|
||||
*/
|
||||
|
||||
class Plugin extends PuppeteerExtraPlugin {
|
||||
constructor(opts = {}) {
|
||||
super(opts)
|
||||
}
|
||||
|
||||
get name() {
|
||||
return 'stealth/evasions/navigator.hardwareConcurrency'
|
||||
}
|
||||
|
||||
get defaults() {
|
||||
return {
|
||||
hardwareConcurrency: 4
|
||||
}
|
||||
}
|
||||
|
||||
async onPageCreated(page) {
|
||||
await withUtils(page).evaluateOnNewDocument(
|
||||
(utils, { opts }) => {
|
||||
utils.replaceGetterWithProxy(
|
||||
Object.getPrototypeOf(navigator),
|
||||
'hardwareConcurrency',
|
||||
utils.makeHandler().getterValue(opts.hardwareConcurrency)
|
||||
)
|
||||
},
|
||||
{
|
||||
opts: this.opts
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = function (pluginConfig) {
|
||||
return new Plugin(pluginConfig)
|
||||
}
|
||||
Reference in New Issue
Block a user