mirror of
https://github.com/TheNetsky/Microsoft-Rewards-Script.git
synced 2026-01-17 21:43:59 +00:00
Port Dockerfile optimizations from v2 to v1.53, no functionality changes. (#386)
* port v2 optimizations to v1.5 Updated dockerfile with v2 optimizations. Ported Login.ts no dialogs fix. * Update entrypoint.sh Fix playwright path in entrypoint as well
This commit is contained in:
committed by
GitHub
parent
14492b27cb
commit
86f65b448d
@@ -347,6 +347,10 @@ export class Login {
|
||||
const targetHostname = 'rewards.bing.com'
|
||||
const targetPathname = '/'
|
||||
|
||||
const start = Date.now()
|
||||
const maxWaitMs = Number(process.env.LOGIN_MAX_WAIT_MS || 180000) // default 3 minutes
|
||||
let guidanceLogged = false
|
||||
|
||||
// eslint-disable-next-line no-constant-condition
|
||||
while (true) {
|
||||
await this.dismissLoginMessages(page)
|
||||
@@ -354,6 +358,18 @@ export class Login {
|
||||
if (currentURL.hostname === targetHostname && currentURL.pathname === targetPathname) {
|
||||
break
|
||||
}
|
||||
|
||||
// If we keep looping without prompts for too long, advise and fail fast
|
||||
const elapsed = Date.now() - start
|
||||
if (elapsed > maxWaitMs) {
|
||||
if (!guidanceLogged) {
|
||||
this.bot.log(this.bot.isMobile, 'LOGIN-GUIDE', 'Login taking too long without prompts.')
|
||||
this.bot.log(this.bot.isMobile, 'LOGIN-GUIDE', 'Tip: Enable passwordless sign-in (Microsoft Authenticator "number match") or add a TOTP secret in accounts.json to auto-fill OTP.')
|
||||
this.bot.log(this.bot.isMobile, 'LOGIN-GUIDE', 'You can also set LOGIN_MAX_WAIT_MS to increase this timeout if needed.')
|
||||
guidanceLogged = true
|
||||
}
|
||||
throw this.bot.log(this.bot.isMobile, 'LOGIN-TIMEOUT', `Login timed out after ${Math.round(elapsed/1000)}s without completing`, 'error')
|
||||
}
|
||||
}
|
||||
|
||||
// Wait for login to complete
|
||||
@@ -543,4 +559,4 @@ export class Login {
|
||||
throw this.bot.log(this.bot.isMobile, 'CHECK-LOCKED', 'This account has been locked! Remove the account from "accounts.json" and restart!', 'error')
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
export PLAYWRIGHT_BROWSERS_PATH=/ms-playwright
|
||||
export PLAYWRIGHT_BROWSERS_PATH=0
|
||||
export TZ="${TZ:-UTC}"
|
||||
|
||||
cd /usr/src/microsoft-rewards-script
|
||||
|
||||
Reference in New Issue
Block a user