Rename to hkt.sh

This commit is contained in:
mango
2026-03-21 01:10:53 +08:00
parent 76a263d0f9
commit 8f1171fe99
6676 changed files with 1724268 additions and 0 deletions

View File

@@ -0,0 +1,48 @@
'use strict'
const { PuppeteerExtraPlugin } = require('puppeteer-extra-plugin')
/**
* Pass the Webdriver Test.
* Will delete `navigator.webdriver` property.
*/
class Plugin extends PuppeteerExtraPlugin {
constructor(opts = {}) {
super(opts)
}
get name() {
return 'stealth/evasions/navigator.webdriver'
}
async onPageCreated(page) {
await page.evaluateOnNewDocument(() => {
if (navigator.webdriver === false) {
// Post Chrome 89.0.4339.0 and already good
} else if (navigator.webdriver === undefined) {
// Pre Chrome 89.0.4339.0 and already good
} else {
// Pre Chrome 88.0.4291.0 and needs patching
delete Object.getPrototypeOf(navigator).webdriver
}
})
}
// Post Chrome 88.0.4291.0
// Note: this will add an infobar to Chrome with a warning that an unsupported flag is set
// To remove this bar on Linux, run: mkdir -p /etc/opt/chrome/policies/managed && echo '{ "CommandLineFlagSecurityWarningsEnabled": false }' > /etc/opt/chrome/policies/managed/managed_policies.json
async beforeLaunch(options) {
// If disable-blink-features is already passed, append the AutomationControlled switch
const idx = options.args.findIndex((arg) => arg.startsWith('--disable-blink-features='));
if (idx !== -1) {
const arg = options.args[idx];
options.args[idx] = `${arg},AutomationControlled`;
} else {
options.args.push('--disable-blink-features=AutomationControlled');
}
}
}
module.exports = function(pluginConfig) {
return new Plugin(pluginConfig)
}

View File

@@ -0,0 +1,44 @@
const test = require('ava')
const { vanillaPuppeteer, addExtra, compareLooseVersionStrings } = require('../../test/util')
const Plugin = require('.')
function getExpectedValue(looseVersionString) {
if (compareLooseVersionStrings(looseVersionString, '89.0.4339.0') >= 0) {
return false
} else {
return undefined
}
}
test('vanilla: navigator.webdriver is defined', async t => {
const browser = await vanillaPuppeteer.launch({ headless: true })
const page = await browser.newPage()
const data = await page.evaluate(() => navigator.webdriver)
t.is(data, true)
})
test('stealth: navigator.webdriver is undefined', async t => {
const puppeteer = addExtra(vanillaPuppeteer).use(Plugin())
const browser = await puppeteer.launch({ headless: true })
const page = await browser.newPage()
const data = await page.evaluate(() => navigator.webdriver)
// XXX: launch this test multiple times with browsers of different versions?
t.is(data, getExpectedValue(await browser.version()))
})
// https://github.com/berstend/puppeteer-extra/pull/130
test('stealth: regression: wont kill other navigator methods', async t => {
const puppeteer = addExtra(vanillaPuppeteer).use(Plugin())
const browser = await puppeteer.launch({ headless: true })
const page = await browser.newPage()
try {
const data = await page.evaluate(() => navigator.javaEnabled())
t.is(data, false)
} catch (err) {
t.is(err, undefined)
}
})

View File

@@ -0,0 +1,4 @@
{
"private": true,
"main": "index.js"
}

View File

@@ -0,0 +1,18 @@
## API
<!-- Generated by documentation.js. Update this documentation by updating the source code. -->
#### Table of Contents
- [class: Plugin](#class-plugin)
### class: [Plugin](https://github.com/berstend/puppeteer-extra/blob/e6133619b051febed630ada35241664eba59b9fa/packages/puppeteer-extra-plugin-stealth/evasions/navigator.webdriver/index.js#L9-L23)
- `opts` (optional, default `{}`)
**Extends: PuppeteerExtraPlugin**
Pass the Webdriver Test.
Will delete `navigator.webdriver` property.
---