mirror of
https://github.com/geekgeekrun/geekgeekrun.git
synced 2026-05-06 20:02:47 +08:00
add and patch AnonymizeUaPlugin; make version of find-chrome-bin fixed
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
"minimist": "^1.2.8",
|
||||
"puppeteer": "24.19.0",
|
||||
"puppeteer-extra": "3.3.6",
|
||||
"puppeteer-extra-plugin-anonymize-ua": "2.4.6",
|
||||
"puppeteer-extra-plugin-stealth": "2.11.2",
|
||||
"rimraf": "^3.0.2",
|
||||
"tapable": "^2.2.1"
|
||||
@@ -33,7 +34,8 @@
|
||||
},
|
||||
"pnpm": {
|
||||
"patchedDependencies": {
|
||||
"find-chrome-bin@2.0.4": "patches/find-chrome-bin@2.0.4.patch"
|
||||
"find-chrome-bin@2.0.4": "patches/find-chrome-bin@2.0.4.patch",
|
||||
"puppeteer-extra-plugin-anonymize-ua@2.4.6": "patches/puppeteer-extra-plugin-anonymize-ua@2.4.6.patch"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,25 +74,29 @@ export const autoStartChatEventBus = new EventEmitter()
|
||||
let puppeteer
|
||||
let StealthPlugin
|
||||
let LaodengPlugin
|
||||
let AnonymizeUaPlugin
|
||||
export async function initPuppeteer () {
|
||||
// production
|
||||
const importResult = await Promise.all(
|
||||
[
|
||||
import('puppeteer-extra'),
|
||||
import('puppeteer-extra-plugin-stealth'),
|
||||
import('@geekgeekrun/puppeteer-extra-plugin-laodeng')
|
||||
import('@geekgeekrun/puppeteer-extra-plugin-laodeng'),
|
||||
import('puppeteer-extra-plugin-anonymize-ua')
|
||||
]
|
||||
)
|
||||
puppeteer = importResult[0].default
|
||||
StealthPlugin = importResult[1].default
|
||||
LaodengPlugin = importResult[2].default
|
||||
AnonymizeUaPlugin = importResult[3].default
|
||||
puppeteer.use(StealthPlugin())
|
||||
puppeteer.use(LaodengPlugin())
|
||||
|
||||
puppeteer.use(AnonymizeUaPlugin())
|
||||
return {
|
||||
puppeteer,
|
||||
StealthPlugin,
|
||||
LaodengPlugin
|
||||
LaodengPlugin,
|
||||
AnonymizeUaPlugin
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@
|
||||
"element-plus": "^2.8.4",
|
||||
"eslint": "^8.56.0",
|
||||
"eslint-plugin-vue": "^9.20.1",
|
||||
"find-chrome-bin": "^2.0.4",
|
||||
"find-chrome-bin": "2.0.4",
|
||||
"js-yaml": "^4.1.0",
|
||||
"normalize.css": "^8.0.1",
|
||||
"prettier": "^3.2.4",
|
||||
|
||||
39
patches/puppeteer-extra-plugin-anonymize-ua@2.4.6.patch
Normal file
39
patches/puppeteer-extra-plugin-anonymize-ua@2.4.6.patch
Normal file
@@ -0,0 +1,39 @@
|
||||
diff --git a/index.js b/index.js
|
||||
index 746525753e19878c0d4711e023e02a77eb5ecf8a..a5c323eb19311235df43c5ae9e0025b7bd1da25d 100644
|
||||
--- a/index.js
|
||||
+++ b/index.js
|
||||
@@ -21,6 +21,7 @@ const { PuppeteerExtraPlugin } = require('puppeteer-extra-plugin')
|
||||
* )
|
||||
* const browser = await puppeteer.launch()
|
||||
*/
|
||||
+
|
||||
class Plugin extends PuppeteerExtraPlugin {
|
||||
constructor(opts = {}) {
|
||||
super(opts)
|
||||
@@ -38,7 +39,7 @@ class Plugin extends PuppeteerExtraPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
- async onPageCreated(page) {
|
||||
+ async handler (page) {
|
||||
let ua = await page.browser().userAgent()
|
||||
if (this.opts.stripHeadless) {
|
||||
ua = ua.replace('HeadlessChrome/', 'Chrome/')
|
||||
@@ -52,6 +53,17 @@ class Plugin extends PuppeteerExtraPlugin {
|
||||
this.debug('new ua', ua)
|
||||
await page.setUserAgent(ua)
|
||||
}
|
||||
+
|
||||
+ async onBrowser(browser) {
|
||||
+ const pages = await browser.pages()
|
||||
+ for (const page of pages) {
|
||||
+ await this.handler(page)
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ async onPageCreated(page) {
|
||||
+ await this.handler(page)
|
||||
+ }
|
||||
}
|
||||
|
||||
module.exports = function(pluginConfig) {
|
||||
32
pnpm-lock.yaml
generated
32
pnpm-lock.yaml
generated
@@ -8,6 +8,9 @@ patchedDependencies:
|
||||
find-chrome-bin@2.0.4:
|
||||
hash: hlvcqc4im4z7xkxtwwtz6sdzui
|
||||
path: patches/find-chrome-bin@2.0.4.patch
|
||||
puppeteer-extra-plugin-anonymize-ua@2.4.6:
|
||||
hash: 5bafoxpvwneq2ywcyjznkii37m
|
||||
path: patches/puppeteer-extra-plugin-anonymize-ua@2.4.6.patch
|
||||
|
||||
importers:
|
||||
|
||||
@@ -34,6 +37,9 @@ importers:
|
||||
puppeteer-extra:
|
||||
specifier: 3.3.6
|
||||
version: 3.3.6(puppeteer@24.19.0)
|
||||
puppeteer-extra-plugin-anonymize-ua:
|
||||
specifier: 2.4.6
|
||||
version: 2.4.6(patch_hash=5bafoxpvwneq2ywcyjznkii37m)(puppeteer-extra@3.3.6)
|
||||
puppeteer-extra-plugin-stealth:
|
||||
specifier: 2.11.2
|
||||
version: 2.11.2(puppeteer-extra@3.3.6)
|
||||
@@ -269,7 +275,7 @@ importers:
|
||||
specifier: ^9.20.1
|
||||
version: 9.20.1(eslint@8.56.0)
|
||||
find-chrome-bin:
|
||||
specifier: ^2.0.4
|
||||
specifier: 2.0.4
|
||||
version: 2.0.4(patch_hash=hlvcqc4im4z7xkxtwwtz6sdzui)
|
||||
js-yaml:
|
||||
specifier: ^4.1.0
|
||||
@@ -1889,7 +1895,7 @@ packages:
|
||||
globby: 11.1.0
|
||||
is-glob: 4.0.3
|
||||
minimatch: 9.0.3
|
||||
semver: 7.6.0
|
||||
semver: 7.7.3
|
||||
ts-api-utils: 1.2.1(typescript@5.3.3)
|
||||
typescript: 5.3.3
|
||||
transitivePeerDependencies:
|
||||
@@ -1909,7 +1915,7 @@ packages:
|
||||
'@typescript-eslint/types': 6.21.0
|
||||
'@typescript-eslint/typescript-estree': 6.21.0(typescript@5.3.3)
|
||||
eslint: 8.56.0
|
||||
semver: 7.6.0
|
||||
semver: 7.7.3
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
- typescript
|
||||
@@ -5591,6 +5597,26 @@ packages:
|
||||
- utf-8-validate
|
||||
dev: false
|
||||
|
||||
/puppeteer-extra-plugin-anonymize-ua@2.4.6(patch_hash=5bafoxpvwneq2ywcyjznkii37m)(puppeteer-extra@3.3.6):
|
||||
resolution: {integrity: sha512-EasOjKpPYFn72Yk7/RXM2q/CDrdPzjTnx8GfHPrwVmhcnh8Ull1DnONP73KZFF2bdwhitaQ3zRZ0yI1yFM2rzQ==}
|
||||
engines: {node: '>=8'}
|
||||
peerDependencies:
|
||||
playwright-extra: '*'
|
||||
puppeteer-extra: '*'
|
||||
peerDependenciesMeta:
|
||||
playwright-extra:
|
||||
optional: true
|
||||
puppeteer-extra:
|
||||
optional: true
|
||||
dependencies:
|
||||
debug: 4.4.3
|
||||
puppeteer-extra: 3.3.6(puppeteer@24.19.0)
|
||||
puppeteer-extra-plugin: 3.2.3(playwright-extra@4.3.6)(puppeteer-extra@3.3.6)
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
dev: false
|
||||
patched: true
|
||||
|
||||
/puppeteer-extra-plugin-stealth@2.11.2(puppeteer-extra@3.3.6):
|
||||
resolution: {integrity: sha512-bUemM5XmTj9i2ZerBzsk2AN5is0wHMNE6K0hXBzBXOzP5m5G3Wl0RHhiqKeHToe/uIH8AoZiGhc1tCkLZQPKTQ==}
|
||||
engines: {node: '>=8'}
|
||||
|
||||
Reference in New Issue
Block a user