mirror of
https://github.com/geekgeekrun/geekgeekrun.git
synced 2026-09-08 00:47:15 +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
|
AnonymizeUaPlugin = importResult[3].default
|
||||||
puppeteer.use(StealthPlugin())
|
puppeteer.use(StealthPlugin())
|
||||||
puppeteer.use(LaodengPlugin())
|
puppeteer.use(LaodengPlugin())
|
||||||
puppeteer.use(AnonymizeUaPlugin())
|
puppeteer.use(AnonymizeUaPlugin({ makeWindows: false }))
|
||||||
return {
|
return {
|
||||||
puppeteer,
|
puppeteer,
|
||||||
StealthPlugin,
|
StealthPlugin,
|
||||||
|
|||||||
@@ -16,8 +16,9 @@ import attachListenerForKillSelfOnParentExited from '../../utils/attachListenerF
|
|||||||
import SqlitePluginModule from '@geekgeekrun/sqlite-plugin'
|
import SqlitePluginModule from '@geekgeekrun/sqlite-plugin'
|
||||||
import gtag from '../../utils/gtag'
|
import gtag from '../../utils/gtag'
|
||||||
import GtagPlugin from '../../utils/gtag/GtagPlugin'
|
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 { PeriodPushCurrentPageScreenshotPlugin } from '../../utils/screenshot'
|
||||||
|
import { checkShouldExit } from '../../utils/worker'
|
||||||
const { default: SqlitePlugin } = SqlitePluginModule
|
const { default: SqlitePlugin } = SqlitePluginModule
|
||||||
|
|
||||||
const rerunInterval = (() => {
|
const rerunInterval = (() => {
|
||||||
@@ -38,19 +39,6 @@ const initPlugins = (hooks) => {
|
|||||||
new PeriodPushCurrentPageScreenshotPlugin().apply(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 runAutoChat = async () => {
|
||||||
const { initPuppeteer, mainLoop, closeBrowserWindow, autoStartChatEventBus } = await import(
|
const { initPuppeteer, mainLoop, closeBrowserWindow, autoStartChatEventBus } = await import(
|
||||||
'@geekgeekrun/geek-auto-start-chat-with-boss/index.mjs'
|
'@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 { JobHireStatus } from '@geekgeekrun/sqlite-plugin/dist/enums';
|
||||||
import dayjs from 'dayjs'
|
import dayjs from 'dayjs'
|
||||||
import cheerio from 'cheerio'
|
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 { pushCurrentPageScreenshot, SCREENSHOT_INTERVAL_MS } from '../../utils/screenshot'
|
||||||
|
import { checkShouldExit } from '../../utils/worker'
|
||||||
|
|
||||||
const throttleIntervalMinutes =
|
const throttleIntervalMinutes =
|
||||||
readConfigFile('boss.json').autoReminder?.throttleIntervalMinutes ?? 10
|
readConfigFile('boss.json').autoReminder?.throttleIntervalMinutes ?? 10
|
||||||
@@ -462,18 +463,6 @@ const rerunInterval = (() => {
|
|||||||
return v
|
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() {
|
export async function runEntry() {
|
||||||
connectToDaemon()
|
connectToDaemon()
|
||||||
app.dock?.hide()
|
app.dock?.hide()
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { sendToDaemon } from "../flow/OPEN_SETTING_WINDOW/connect-to-daemon"
|
import { sendToDaemon } from "../flow/OPEN_SETTING_WINDOW/connect-to-daemon"
|
||||||
|
import { checkShouldExit } from "./worker"
|
||||||
|
|
||||||
export const SCREENSHOT_INTERVAL_MS = 2500
|
export const SCREENSHOT_INTERVAL_MS = 2500
|
||||||
|
|
||||||
@@ -43,6 +44,10 @@ export class PeriodPushCurrentPageScreenshotPlugin {
|
|||||||
if (page.isClosed()) {
|
if (page.isClosed()) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
const shouldExit = await checkShouldExit()
|
||||||
|
if (shouldExit) {
|
||||||
|
return
|
||||||
|
}
|
||||||
await pushCurrentPageScreenshot(page)
|
await pushCurrentPageScreenshot(page)
|
||||||
setTimeout(periodPushCurrentPageScreenshot, SCREENSHOT_INTERVAL_MS)
|
setTimeout(periodPushCurrentPageScreenshot, SCREENSHOT_INTERVAL_MS)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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