From d6ba5aeae603f7e460fae14ff2bcad80c5a49f4a Mon Sep 17 00:00:00 2001 From: Sucukdeluxe Date: Fri, 6 Mar 2026 11:35:45 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(bestdebrid):=20keep=20CDP=20?= =?UTF-8?q?debugger=20attached=20until=20window=20close?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Detaching the debugger before loadURL removed the registered anti-fingerprint scripts, causing blank pages. Now keep the debugger attached through page load and detach on window close. Co-Authored-By: Claude Opus 4.6 --- src/main/bestdebrid-web.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/bestdebrid-web.ts b/src/main/bestdebrid-web.ts index 18d9fdc..5480b6e 100644 --- a/src/main/bestdebrid-web.ts +++ b/src/main/bestdebrid-web.ts @@ -193,10 +193,13 @@ export class BestDebridWebFallback { window.webContents.setUserAgent(BESTDEBRID_USER_AGENT); window.setMenuBarVisibility(false); - // Inject anti-fingerprint patches via CDP before any page JS runs - // This hides Electron-specific properties that Cloudflare Turnstile detects + // Inject anti-fingerprint patches via CDP before any page JS runs. + // The debugger must stay attached until after page load so the + // registered scripts actually execute on every new document. + let debuggerAttached = false; try { window.webContents.debugger.attach("1.3"); + debuggerAttached = true; await window.webContents.debugger.sendCommand("Page.addScriptToEvaluateOnNewDocument", { source: [ "Object.defineProperty(navigator, 'webdriver', { get: () => false });", @@ -205,12 +208,14 @@ export class BestDebridWebFallback { "window.chrome = { runtime: {}, loadTimes: function() {}, csi: function() {} };" ].join("\n") }); - window.webContents.debugger.detach(); } catch { // CDP not available — continue without patches } window.on("closed", () => { + if (debuggerAttached) { + try { window.webContents.debugger.detach(); } catch { /* already detached */ } + } if (this.loginWindow === window) { this.loginWindow = null; this.loginWindowPartition = "";