mirror of
https://github.com/geekgeekrun/geekgeekrun.git
synced 2026-09-07 00:17:17 +08:00
change the way for importing puppeteer to work with ui
This commit is contained in:
@@ -1,6 +1,3 @@
|
|||||||
import puppeteer from 'puppeteer-extra';
|
|
||||||
import StealthPlugin from 'puppeteer-extra-plugin-stealth'
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
sleep,
|
sleep,
|
||||||
sleepWithRandomDelay
|
sleepWithRandomDelay
|
||||||
@@ -14,7 +11,21 @@ import JSON5 from 'json5'
|
|||||||
import { readConfigFile, ensureConfigFileExist } from './runtime-file-utils.mjs'
|
import { readConfigFile, ensureConfigFileExist } from './runtime-file-utils.mjs'
|
||||||
ensureConfigFileExist()
|
ensureConfigFileExist()
|
||||||
|
|
||||||
puppeteer.use(StealthPlugin())
|
let puppeteer
|
||||||
|
async function initPuppeteer () {
|
||||||
|
const [
|
||||||
|
puppeteerModule,
|
||||||
|
StealthPluginModule,
|
||||||
|
] = await Promise.all(
|
||||||
|
[
|
||||||
|
import('puppeteer-extra'),
|
||||||
|
import('puppeteer-extra-plugin-stealth')
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
puppeteerModule.default.use(StealthPluginModule.default())
|
||||||
|
puppeteer = puppeteerModule.default
|
||||||
|
}
|
||||||
|
|
||||||
const { cookies: bossCookies } = readConfigFile('boss.json')
|
const { cookies: bossCookies } = readConfigFile('boss.json')
|
||||||
|
|
||||||
@@ -29,6 +40,9 @@ let browser, page
|
|||||||
|
|
||||||
const blockBossNotNewChat = new Set()
|
const blockBossNotNewChat = new Set()
|
||||||
export async function mainLoop (hooks) {
|
export async function mainLoop (hooks) {
|
||||||
|
if (!puppeteer) {
|
||||||
|
await initPuppeteer()
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
browser = await puppeteer.launch({
|
browser = await puppeteer.launch({
|
||||||
headless: false,
|
headless: false,
|
||||||
|
|||||||
Reference in New Issue
Block a user