diff --git a/epic-claimer-new.js b/epic-claimer-new.js index ad3609e..290e66e 100644 --- a/epic-claimer-new.js +++ b/epic-claimer-new.js @@ -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()) { 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.`); @@ -155,6 +161,13 @@ const ensureLoggedIn = async (page, context) => { console.info(`Login timeout is ${cfg.login_timeout / 1000} seconds!`); 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(); if (logged) break;