mirror of
https://github.com/geekgeekrun/geekgeekrun.git
synced 2026-07-07 23:31:24 +08:00
don't make browser to be like windows; check if page closed before push screenshot
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
14
packages/ui/src/main/utils/worker.ts
Normal file
14
packages/ui/src/main/utils/worker.ts
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user