From 32bcd8ba37dbe99dda88b7dcf14452d020b24cd6 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 17 Nov 2025 10:41:41 +0000 Subject: [PATCH 1/2] Initial plan From 4fb2c871f6f829b08f53b1c6af7c553751498e31 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 17 Nov 2025 10:45:24 +0000 Subject: [PATCH 2/2] Fix service worker ReadableStream error for recaptcha Co-authored-by: sriail <225764385+sriail@users.noreply.github.com> --- public/sw.js | 51 ++++----------------------------------------------- 1 file changed, 4 insertions(+), 47 deletions(-) diff --git a/public/sw.js b/public/sw.js index efad95a..6ce5df7 100644 --- a/public/sw.js +++ b/public/sw.js @@ -6,65 +6,22 @@ const uv = new UVServiceWorker(); const { ScramjetServiceWorker } = $scramjetLoadWorker(); const sj = new ScramjetServiceWorker(); -// Enhanced CAPTCHA and Cloudflare verification support -// List of CAPTCHA and verification domains that need special handling -const CAPTCHA_DOMAINS = [ - "google.com/recaptcha", - "www.google.com/recaptcha", - "recaptcha.net", - "www.recaptcha.net", - "gstatic.com/recaptcha", - "hcaptcha.com", - "newassets.hcaptcha.com", - "challenges.cloudflare.com", - "cloudflare.com/cdn-cgi/challenge", - "turnstile.cloudflare.com" -]; - -// Helper function to check if URL is CAPTCHA-related -function isCaptchaRequest(url) { - const urlStr = url.toString().toLowerCase(); - return CAPTCHA_DOMAINS.some((domain) => urlStr.includes(domain)); -} - -// Helper function to ensure proper CAPTCHA handling -function enhanceCaptchaRequest(request) { - // Clone the request to ensure all headers and properties are preserved - const headers = new Headers(request.headers); - - // Ensure proper headers for CAPTCHA requests - if (!headers.has("Accept")) { - headers.set("Accept", "*/*"); - } - - // Preserve credentials for CAPTCHA cookies - return new Request(request, { - headers: headers, - credentials: "include", - mode: request.mode === "navigate" ? "same-origin" : request.mode - }); -} - self.addEventListener("fetch", function (event) { event.respondWith( (async () => { await sj.loadConfig(); const url = event.request.url; - const isCaptcha = isCaptchaRequest(url); - - // Enhanced handling for CAPTCHA requests - let request = event.request; - if (isCaptcha) { - request = enhanceCaptchaRequest(event.request); - } + // Route to appropriate proxy handler + // Both UV and Scramjet handle CAPTCHA requests properly when given the original event if (url.startsWith(location.origin + __uv$config.prefix)) { return await uv.fetch(event); } else if (sj.route(event)) { return await sj.fetch(event); } else { - return await fetch(request); + // For non-proxied requests, use the original request to avoid stream issues + return await fetch(event.request); } })() );