fix: detect cloudflare challenge and wait for manual solve in new epic claimer
Some checks failed
build-and-push / lint (push) Failing after 4s
build-and-push / sonar (push) Has been skipped
build-and-push / docker (push) Has been skipped

This commit is contained in:
nocci 2025-12-31 13:18:28 +00:00
parent 1a34d8f0e4
commit 1c34648112

View file

@ -148,6 +148,12 @@ const ensureLoggedIn = async (page, context) => {
} }
}; };
const isChallenge = async () => {
const cfFrame = page.locator('iframe[title*="Cloudflare"], iframe[src*="challenges"]');
const cfText = page.locator('text=Verify you are human');
return (await cfFrame.count()) > 0 || (await cfText.count()) > 0;
};
while (!await isLoggedIn()) { while (!await isLoggedIn()) {
console.error('Not signed in anymore. Trying automatic login, otherwise please login in the browser.'); console.error('Not signed in anymore. Trying automatic login, otherwise please login in the browser.');
if (cfg.novnc_port) console.info(`Open http://localhost:${cfg.novnc_port} to login inside the docker container.`); if (cfg.novnc_port) console.info(`Open http://localhost:${cfg.novnc_port} to login inside the docker container.`);
@ -155,6 +161,13 @@ const ensureLoggedIn = async (page, context) => {
console.info(`Login timeout is ${cfg.login_timeout / 1000} seconds!`); console.info(`Login timeout is ${cfg.login_timeout / 1000} seconds!`);
await page.goto(URL_CLAIM, { waitUntil: 'domcontentloaded' }); await page.goto(URL_CLAIM, { waitUntil: 'domcontentloaded' });
if (await isChallenge()) {
console.warn('Cloudflare challenge detected. Solve the captcha in the browser (no automation).');
await notify('epic-games (new): Cloudflare challenge, please solve manually in browser.');
await page.waitForTimeout(cfg.login_timeout);
continue;
}
const logged = await attemptAutoLogin(); const logged = await attemptAutoLogin();
if (logged) break; if (logged) break;