diff --git a/src/browser/Browser.ts b/src/browser/Browser.ts index 0d281a7..fb82afe 100644 --- a/src/browser/Browser.ts +++ b/src/browser/Browser.ts @@ -182,6 +182,32 @@ class Browser { try { context.on('page', async (page) => { try { + // CRITICAL: Install dialog handlers FIRST to prevent Bluetooth/Passkey native popups + page.removeAllListeners('dialog') + page.on('dialog', async (dialog) => { + const message = dialog.message() + const type = dialog.type() + + this.bot.log( + this.bot.isMobile, + 'BROWSER-DIALOG', + `Native dialog: [${type}] "${message.substring(0, 50)}"`, + 'warn' + ) + + try { + if (type === 'beforeunload') { + await dialog.accept() + } else { + // Dismiss all other dialogs (Bluetooth, Passkey, Windows Hello) + await dialog.dismiss() + this.bot.log(this.bot.isMobile, 'BROWSER-DIALOG', `Dismissed ${type} dialog`, 'log', 'green') + } + } catch (e) { + this.bot.log(this.bot.isMobile, 'BROWSER-DIALOG', `Dialog error: ${e instanceof Error ? e.message : String(e)}`, 'error') + } + }) + // CRITICAL: Inject anti-detection scripts BEFORE any page load await page.addInitScript(antiDetectScript) await page.addInitScript(timezoneScript) diff --git a/src/functions/Login.ts b/src/functions/Login.ts index c126577..4504607 100644 --- a/src/functions/Login.ts +++ b/src/functions/Login.ts @@ -228,10 +228,6 @@ export class Login { await this.disableFido(page) - // CRITICAL: Setup dialog handlers BEFORE any login interactions - // This prevents native browser dialogs (Bluetooth, Windows Hello, Passkey) from blocking automation - this.passkeyHandler.setupDialogHandlers(page) - const [reloadResult, totpResult, portalCheck] = await Promise.allSettled([ this.bot.browser.utils.reloadBadPage(page), this.totpHandler.tryAutoTotp(page, 'initial landing'),