From 9f5601d44bf95e4619da80c66cf79dde3dae2017 Mon Sep 17 00:00:00 2001 From: hmcdat <90164248+hmcdat@users.noreply.github.com> Date: Fri, 30 May 2025 16:43:15 +0700 Subject: [PATCH] Fix 2FA problem on new login page (#305) * fix 2FA on new login page * change 2fa login checking element * temporary disable parallel due to errors when script tries to dismiss buttons --- src/config.json | 2 +- src/functions/Login.ts | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/config.json b/src/config.json index 9d0aa1e..5be6f24 100644 --- a/src/config.json +++ b/src/config.json @@ -2,7 +2,7 @@ "baseURL": "https://rewards.bing.com", "sessionPath": "sessions", "headless": false, - "parallel": true, + "parallel": false, "runOnZeroPoints": false, "clusters": 1, "saveFingerprint": { diff --git a/src/functions/Login.ts b/src/functions/Login.ts index 7428599..6cab2f8 100644 --- a/src/functions/Login.ts +++ b/src/functions/Login.ts @@ -177,7 +177,7 @@ export class Login { private async get2FACode(page: Page): Promise { try { - const element = await page.waitForSelector('#displaySign', { state: 'visible', timeout: 2000 }) + const element = await page.waitForSelector('#displaySign, div[data-testid="displaySign"]>span', { state: 'visible', timeout: 2000 }) return await element.textContent() } catch { if (this.bot.config.parallel) { @@ -200,7 +200,7 @@ export class Login { await page.click('button[aria-describedby="confirmSendTitle"]').catch(() => { }) await this.bot.utils.wait(2000) - const element = await page.waitForSelector('#displaySign', { state: 'visible', timeout: 2000 }) + const element = await page.waitForSelector('#displaySign, div[data-testid="displaySign"]>span', { state: 'visible', timeout: 2000 }) return await element.textContent() } } @@ -212,7 +212,7 @@ export class Login { this.bot.log(this.bot.isMobile, 'LOGIN', `Press the number ${numberToPress} on your Authenticator app to approve the login`) this.bot.log(this.bot.isMobile, 'LOGIN', 'If you press the wrong number or the "DENY" button, try again in 60 seconds') - await page.waitForSelector('#i0281', { state: 'detached', timeout: 60000 }) + await page.waitForSelector('form[name="f1"]', { state: 'detached', timeout: 60000 }) this.bot.log(this.bot.isMobile, 'LOGIN', 'Login successfully approved!') break