SPB Git

spb/fetcha

Public

browser: detect challenge completion by interstitial markers only (beacon URLs on the real page kept it 'blocked')

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Simon-Pierre Boucher committed (Sep 8, 2026) parent 0f06945 Browse files

1 changed file +3 −1

Unified Split
modified packages/browser/src/index.ts +3 −1
@@ -464,7 +464,9 @@ export class BrowserPool {
464 headers = lower(navResp.headers()); 464 headers = lower(navResp.headers());
465 } 465 }
466 html = await page.content().catch(() => ""); 466 html = await page.content().catch(() => "");
467− const stillChallenge = CHALLENGE_SELECTORS.some((sel) => html.includes(sel.replace(/^[#.]/, "")) && /challenge|turnstile|captcha|datadome|px-/i.test(sel)) && looksBlocked(status, html, headers).blocked; 467+ // Interstitial markers only: the real page of a protected site also references
468+ // challenges.cloudflare.com (beacon), so vendor script URLs must not count here.
469+ const stillChallenge = /cf_chl_opt|__cf_chl_|id="challenge-(running|stage|form|error-text)"|<title>\s*Just a moment|id="px-captcha"|geo\.captcha-delivery\.com|id="datadome"|Verifying you are human|Performing security verification/i.test(html.slice(0, 60_000));
468 const v = looksBlocked(navResp ? status : 200, html, headers); 470 const v = looksBlocked(navResp ? status : 200, html, headers);
469 if (!v.blocked && !stillChallenge && html.length > 1500) { 471 if (!v.blocked && !stillChallenge && html.length > 1500) {
470 challengeSolved = true; 472 challengeSolved = true;
471 473
Menu

Theme