don't make browser to be like windows; check if page closed before push screenshot

This commit is contained in:
geekgeekrun
2026-01-15 17:20:10 +08:00
parent 6f02160f28
commit 492538e663
5 changed files with 24 additions and 28 deletions

View File

@@ -91,7 +91,7 @@ export async function initPuppeteer () {
AnonymizeUaPlugin = importResult[3].default
puppeteer.use(StealthPlugin())
puppeteer.use(LaodengPlugin())
puppeteer.use(AnonymizeUaPlugin())
puppeteer.use(AnonymizeUaPlugin({ makeWindows: false }))
return {
puppeteer,
StealthPlugin,

View File

@@ -16,8 +16,9 @@ import attachListenerForKillSelfOnParentExited from '../../utils/attachListenerF
import SqlitePluginModule from '@geekgeekrun/sqlite-plugin'
import gtag from '../../utils/gtag'
import GtagPlugin from '../../utils/gtag/GtagPlugin'
import { connectToDaemon, sendToDaemon } from '../OPEN_SETTING_WINDOW/connect-to-daemon'
import { connectToDaemon } from '../OPEN_SETTING_WINDOW/connect-to-daemon'
import { PeriodPushCurrentPageScreenshotPlugin } from '../../utils/screenshot'
import { checkShouldExit } from '../../utils/worker'
const { default: SqlitePlugin } = SqlitePluginModule
const rerunInterval = (() => {
@@ -38,19 +39,6 @@ const initPlugins = (hooks) => {
new PeriodPushCurrentPageScreenshotPlugin().apply(hooks)
}
async function checkShouldExit () {
const shouldExitResponse = await sendToDaemon(
{
type: 'check-should-exit',
workerId: process.env.GEEKGEEKRUND_WORKER_ID,
},
{
needCallback: true
}
)
return shouldExitResponse?.shouldExit
}
const runAutoChat = async () => {
const { initPuppeteer, mainLoop, closeBrowserWindow, autoStartChatEventBus } = await import(
'@geekgeekrun/geek-auto-start-chat-with-boss/index.mjs'

View File

@@ -24,8 +24,9 @@ import gtag from '../../utils/gtag'
import { JobHireStatus } from '@geekgeekrun/sqlite-plugin/dist/enums';
import dayjs from 'dayjs'
import cheerio from 'cheerio'
import { connectToDaemon, sendToDaemon } from '../OPEN_SETTING_WINDOW/connect-to-daemon'
import { connectToDaemon } from '../OPEN_SETTING_WINDOW/connect-to-daemon'
import { pushCurrentPageScreenshot, SCREENSHOT_INTERVAL_MS } from '../../utils/screenshot'
import { checkShouldExit } from '../../utils/worker'
const throttleIntervalMinutes =
readConfigFile('boss.json').autoReminder?.throttleIntervalMinutes ?? 10
@@ -462,18 +463,6 @@ const rerunInterval = (() => {
return v
})()
async function checkShouldExit () {
const shouldExitResponse = await sendToDaemon(
{
type: 'check-should-exit',
workerId: process.env.GEEKGEEKRUND_WORKER_ID,
},
{
needCallback: true
}
)
return shouldExitResponse?.shouldExit
}
export async function runEntry() {
connectToDaemon()
app.dock?.hide()

View File

@@ -1,4 +1,5 @@
import { sendToDaemon } from "../flow/OPEN_SETTING_WINDOW/connect-to-daemon"
import { checkShouldExit } from "./worker"
export const SCREENSHOT_INTERVAL_MS = 2500
@@ -43,6 +44,10 @@ export class PeriodPushCurrentPageScreenshotPlugin {
if (page.isClosed()) {
return
}
const shouldExit = await checkShouldExit()
if (shouldExit) {
return
}
await pushCurrentPageScreenshot(page)
setTimeout(periodPushCurrentPageScreenshot, SCREENSHOT_INTERVAL_MS)
}

View File

@@ -0,0 +1,14 @@
import { sendToDaemon } from "../flow/OPEN_SETTING_WINDOW/connect-to-daemon"
export async function checkShouldExit () {
const shouldExitResponse = await sendToDaemon(
{
type: 'check-should-exit',
workerId: process.env.GEEKGEEKRUND_WORKER_ID,
},
{
needCallback: true
}
)
return shouldExitResponse?.shouldExit
}