fix(stealth): bypass worker wrapping in cloudflare challenge runtime
This commit is contained in:
@@ -1268,6 +1268,19 @@ function patchNavigatorConnection(): string {
|
|||||||
function patchWorkerConnection(): string {
|
function patchWorkerConnection(): string {
|
||||||
return `(function(){
|
return `(function(){
|
||||||
if (typeof Worker !== 'function') return;
|
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 NativeWorker = Worker;
|
||||||
const workerPrelude = \`
|
const workerPrelude = \`
|
||||||
(() => {
|
(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user