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,47 @@
'use strict'
const { PuppeteerExtraPlugin } = require('puppeteer-extra-plugin')
const argsToIgnore = [
'--disable-extensions',
'--disable-default-apps',
'--disable-component-extensions-with-background-pages'
]
/**
* A CDP driver like puppeteer can make use of various browser launch arguments that are
* adversarial to mimicking a regular browser and need to be stripped when launching the browser.
*/
class Plugin extends PuppeteerExtraPlugin {
constructor(opts = {}) {
super(opts)
}
get name() {
return 'stealth/evasions/defaultArgs'
}
get requirements() {
return new Set(['runLast']) // So other plugins can modify launch options before
}
async beforeLaunch(options = {}) {
options.ignoreDefaultArgs = options.ignoreDefaultArgs || []
if (options.ignoreDefaultArgs === true) {
// that means the user explicitly wants to disable all default arguments
return
}
argsToIgnore.forEach(arg => {
if (options.ignoreDefaultArgs.includes(arg)) {
return
}
options.ignoreDefaultArgs.push(arg)
})
}
}
module.exports = function (pluginConfig) {
return new Plugin(pluginConfig)
}
module.exports.argsToIgnore = argsToIgnore

View File

@@ -0,0 +1,36 @@
const test = require('ava')
const { vanillaPuppeteer, addExtra } = require('../../test/util')
const Plugin = require('.')
const { argsToIgnore } = require('.')
test('vanilla: uses args to ignore', async t => {
const browser = await vanillaPuppeteer.launch({ headless: true })
const page = await browser.newPage()
const client =
typeof page._client === 'function' ? page._client() : page._client
const { arguments: launchArgs } = await client.send(
'Browser.getBrowserCommandLine'
)
const ok = argsToIgnore.every(arg => launchArgs.includes(arg))
if (!ok) {
console.log({ argsToIgnore, launchArgs })
}
t.is(ok, true)
})
test('stealth: does not use args to ignore', async t => {
const puppeteer = addExtra(vanillaPuppeteer).use(Plugin())
const browser = await puppeteer.launch({ headless: true })
const page = await browser.newPage()
const client =
typeof page._client === 'function' ? page._client() : page._client
const { arguments: launchArgs } = await client.send(
'Browser.getBrowserCommandLine'
)
const ok = argsToIgnore.every(arg => !launchArgs.includes(arg))
if (!ok) {
console.log({ argsToIgnore, launchArgs })
}
t.is(ok, true)
})

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/358246d5cc56bbb8800624128503482b8d7b426a/packages/puppeteer-extra-plugin-stealth/evasions/defaultArgs/index.js#L15-L41)
- `opts` (optional, default `{}`)
**Extends: PuppeteerExtraPlugin**
A CDP driver like puppeteer can make use of various browser launch arguments that are
adversarial to mimicking a regular browser and need to be stripped when launching the browser.
---