mirror of
https://github.com/LightZirconite/Microsoft-Rewards-Bot.git
synced 2026-01-10 17:26:17 +00:00
feat: add early exit handling for passkey creation flows and implement click logic for visible buttons
This commit is contained in:
@@ -34,6 +34,24 @@ export class PasskeyHandler {
|
|||||||
public async handlePasskeyPrompts(page: Page, context: 'main' | 'oauth') {
|
public async handlePasskeyPrompts(page: Page, context: 'main' | 'oauth') {
|
||||||
let did = false
|
let did = false
|
||||||
|
|
||||||
|
// Early exit for passkey creation flows (common on mobile): hit cancel/skip if present
|
||||||
|
const currentUrl = page.url()
|
||||||
|
if (/fido\/create|passkey/i.test(currentUrl)) {
|
||||||
|
const cancelled = await this.clickFirstVisible(page, [
|
||||||
|
'button:has-text("Cancel")',
|
||||||
|
'button:has-text("Not now")',
|
||||||
|
'button:has-text("Skip")',
|
||||||
|
'button:has-text("No thanks")',
|
||||||
|
'[data-testid="secondaryButton"]',
|
||||||
|
'button[class*="secondary"]'
|
||||||
|
], 500)
|
||||||
|
|
||||||
|
if (cancelled) {
|
||||||
|
did = true
|
||||||
|
this.logPasskeyOnce('fido/create cancel')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Priority 1: Direct detection of "Skip for now" button by data-testid
|
// Priority 1: Direct detection of "Skip for now" button by data-testid
|
||||||
const skipBtnResult = await waitForElementSmart(page, 'button[data-testid="secondaryButton"]', {
|
const skipBtnResult = await waitForElementSmart(page, 'button[data-testid="secondaryButton"]', {
|
||||||
initialTimeoutMs: 300,
|
initialTimeoutMs: 300,
|
||||||
@@ -196,6 +214,18 @@ export class PasskeyHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async clickFirstVisible(page: Page, selectors: string[], timeoutMs = 300): Promise<boolean> {
|
||||||
|
for (const selector of selectors) {
|
||||||
|
const el = page.locator(selector).first()
|
||||||
|
const visible = await el.isVisible({ timeout: timeoutMs }).catch(() => false)
|
||||||
|
if (!visible) continue
|
||||||
|
|
||||||
|
await el.click().catch(logError('LOGIN-PASSKEY', `Click failed for ${selector}`, this.bot.isMobile))
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
private logPasskeyOnce(reason: string) {
|
private logPasskeyOnce(reason: string) {
|
||||||
if (this.passkeyHandled) return
|
if (this.passkeyHandled) return
|
||||||
this.passkeyHandled = true
|
this.passkeyHandled = true
|
||||||
|
|||||||
Reference in New Issue
Block a user