diff --git a/src/lib/services/cf-fetch.ts b/src/lib/services/cf-fetch.ts index 96fbeb88..787c2381 100644 --- a/src/lib/services/cf-fetch.ts +++ b/src/lib/services/cf-fetch.ts @@ -49,15 +49,20 @@ export async function fetchWithCfBypass( status === 403; if (isCfChallenge) { - await page.waitForFunction( - () => - !document.body.innerHTML.includes("Attention Required") && - !document.body.innerHTML.includes("Checking your browser") && - !document.body.innerHTML.includes("Just a moment"), - { timeout: 10000 }, - ); + try { + await page.waitForFunction( + () => + document.body.innerHTML.includes("cf-captcha") || + document.body.innerHTML.includes("challenge-platform"), + { timeout: 5000 }, + ); + } catch { + // CF challenge might have been solved already + } } + await new Promise((resolve) => setTimeout(resolve, 2000)); + const finalBody = await page.content(); return finalBody; } finally {