Added dialog handlers to prevent native pop-ups when using the browser and removed the old dialog handling code in the login process.

This commit is contained in:
2025-12-22 22:19:48 +01:00
parent 94272ac7f3
commit a80321274f
2 changed files with 26 additions and 4 deletions

View File

@@ -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)

View File

@@ -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'),