mirror of
https://github.com/LightZirconite/Microsoft-Rewards-Bot.git
synced 2026-01-09 00:56:16 +00:00
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:
@@ -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)
|
||||
|
||||
@@ -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'),
|
||||
|
||||
Reference in New Issue
Block a user