fix: check consent button every second
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
import type { Page } from "patchright";
|
||||
import logger from "../logger";
|
||||
|
||||
async function init(page: Page, spawnId: string = "unknown") {
|
||||
async function checkConsentButton(page: Page, spawnId: string = "unknown") {
|
||||
const consentButton = page.locator("button[data-a-target='consent-banner-accept']");
|
||||
if ((await consentButton.all()).length > 0) {
|
||||
logger.debug(`[${spawnId}] Consent button found, clicking it...`);
|
||||
@ -21,7 +21,10 @@ async function keepAlive(page: Page, spawnId: string = "unknown") {
|
||||
if ((await page.locator(".ScCoreButton-sc-ocjdkq-0.ggPgVz").all()).length > 0) {
|
||||
logger.debug(`[${spawnId}] Player encountered an error, refreshing the page...`);
|
||||
await page.reload({timeout: 0, waitUntil: "domcontentloaded"});
|
||||
waitTime = 0;
|
||||
continue;
|
||||
}
|
||||
await checkConsentButton(page, spawnId);
|
||||
if (waitTime > 5 * 60 * 1000) {
|
||||
logger.debug(`[${spawnId}] Waited for more than 5 minutes, refreshing the page...`);
|
||||
await page.reload({timeout: 0, waitUntil: "domcontentloaded"});
|
||||
@ -33,4 +36,4 @@ async function keepAlive(page: Page, spawnId: string = "unknown") {
|
||||
}
|
||||
}
|
||||
|
||||
export { init, keepAlive };
|
||||
export { keepAlive };
|
||||
|
||||
Reference in New Issue
Block a user