From 59589043db6af345f991606ad4e72a3688f86c1c Mon Sep 17 00:00:00 2001 From: leeguooooo Date: Wed, 4 Mar 2026 13:48:16 +0900 Subject: [PATCH] fix(stealth): bypass worker wrapping in cloudflare challenge runtime --- src/stealth.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/stealth.ts b/src/stealth.ts index aa80ff2..902e4c4 100644 --- a/src/stealth.ts +++ b/src/stealth.ts @@ -1268,6 +1268,19 @@ function patchNavigatorConnection(): string { function patchWorkerConnection(): string { return `(function(){ if (typeof Worker !== 'function') return; + const isCloudflareChallengeRuntime = (() => { + try { + const host = String(location.hostname || '').toLowerCase(); + const path = String(location.pathname || ''); + if (host === 'challenges.cloudflare.com') return true; + return /\\/cdn-cgi\\/challenge-platform\\//.test(path); + } catch { + return false; + } + })(); + // Cloudflare challenge workers are sensitive to constructor wrapping. + // Keep native Worker behavior in this runtime to avoid importScripts(blob) failures. + if (isCloudflareChallengeRuntime) return; const NativeWorker = Worker; const workerPrelude = \` (() => {