mirror of
https://github.com/LightZirconite/Microsoft-Rewards-Bot.git
synced 2026-01-28 16:31:01 +00:00
Patch 2
This commit is contained in:
@@ -52,29 +52,18 @@ class Browser {
|
|||||||
'--ignore-ssl-errors'
|
'--ignore-ssl-errors'
|
||||||
]
|
]
|
||||||
|
|
||||||
// Linux-specific args to fix DNS resolution & chrome-error://chromewebdata/ issues
|
// Minimal Linux fixes for DNS/network issues without detection risk
|
||||||
// These fixes apply to ALL Linux distributions (Ubuntu, Debian, Raspberry Pi OS, etc.)
|
// Only adds essential stability flags that don't trigger bot detection
|
||||||
// Fixes navigation interrupted errors caused by DNS timeouts & network service issues
|
const linuxStabilityArgs = isLinux ? [
|
||||||
const linuxNetworkFixArgs = isLinux ? [
|
|
||||||
'--disable-features=NetworkService',
|
|
||||||
'--disable-features=VizDisplayCompositor',
|
|
||||||
'--enable-features=NetworkServiceInProcess',
|
|
||||||
'--disable-dev-shm-usage',
|
'--disable-dev-shm-usage',
|
||||||
'--disable-software-rasterizer',
|
'--disable-software-rasterizer'
|
||||||
'--disable-gpu',
|
|
||||||
'--disable-features=IsolateOrigins,site-per-process',
|
|
||||||
'--disable-site-isolation-trials',
|
|
||||||
'--dns-prefetch-disable',
|
|
||||||
'--no-zygote',
|
|
||||||
'--single-process',
|
|
||||||
'--disable-blink-features=AutomationControlled'
|
|
||||||
] : []
|
] : []
|
||||||
|
|
||||||
browser = await playwright.chromium.launch({
|
browser = await playwright.chromium.launch({
|
||||||
headless,
|
headless,
|
||||||
...(proxyConfig && { proxy: proxyConfig }),
|
...(proxyConfig && { proxy: proxyConfig }),
|
||||||
args: [...baseArgs, ...linuxNetworkFixArgs],
|
args: [...baseArgs, ...linuxStabilityArgs],
|
||||||
timeout: isLinux ? 120000 : 60000
|
timeout: isLinux ? 90000 : 60000
|
||||||
})
|
})
|
||||||
} catch (e: unknown) {
|
} catch (e: unknown) {
|
||||||
const msg = (e instanceof Error ? e.message : String(e))
|
const msg = (e instanceof Error ? e.message : String(e))
|
||||||
|
|||||||
@@ -102,14 +102,36 @@ export class Login {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use longer timeout on Linux due to DNS resolution issues
|
|
||||||
const isLinux = process.platform === 'linux'
|
const isLinux = process.platform === 'linux'
|
||||||
const navigationTimeout = isLinux ? 45000 : 30000
|
const navigationTimeout = isLinux ? 60000 : 30000
|
||||||
|
|
||||||
await page.goto('https://www.bing.com/rewards/dashboard', {
|
// Retry mechanism for Linux DNS issues
|
||||||
waitUntil: 'domcontentloaded',
|
let lastError: Error | null = null
|
||||||
timeout: navigationTimeout
|
for (let attempt = 1; attempt <= 3; attempt++) {
|
||||||
})
|
try {
|
||||||
|
await page.goto('https://www.bing.com/rewards/dashboard', {
|
||||||
|
waitUntil: 'domcontentloaded',
|
||||||
|
timeout: navigationTimeout
|
||||||
|
})
|
||||||
|
lastError = null
|
||||||
|
break
|
||||||
|
} catch (e) {
|
||||||
|
lastError = e as Error
|
||||||
|
const errorMsg = e instanceof Error ? e.message : String(e)
|
||||||
|
|
||||||
|
// Only retry on chrome-error or timeout, not on HTTP errors (400, 403, etc.)
|
||||||
|
if (errorMsg.includes('chrome-error://chromewebdata/') || errorMsg.includes('Timeout')) {
|
||||||
|
if (attempt < 3) {
|
||||||
|
this.bot.log(this.bot.isMobile, 'LOGIN', `Navigation failed (attempt ${attempt}/3), retrying...`, 'warn')
|
||||||
|
await this.bot.utils.wait(2000 * attempt)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw e
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lastError) throw lastError
|
||||||
await this.disableFido(page)
|
await this.disableFido(page)
|
||||||
|
|
||||||
const [, , portalCheck] = await Promise.allSettled([
|
const [, , portalCheck] = await Promise.allSettled([
|
||||||
@@ -159,8 +181,23 @@ export class Login {
|
|||||||
url.searchParams.set('login_hint', email)
|
url.searchParams.set('login_hint', email)
|
||||||
|
|
||||||
const isLinux = process.platform === 'linux'
|
const isLinux = process.platform === 'linux'
|
||||||
const navigationTimeout = isLinux ? 45000 : 30000
|
const navigationTimeout = isLinux ? 60000 : 30000
|
||||||
await page.goto(url.href, { waitUntil: 'domcontentloaded', timeout: navigationTimeout })
|
|
||||||
|
// Retry for Linux DNS issues
|
||||||
|
for (let attempt = 1; attempt <= 3; attempt++) {
|
||||||
|
try {
|
||||||
|
await page.goto(url.href, { waitUntil: 'domcontentloaded', timeout: navigationTimeout })
|
||||||
|
break
|
||||||
|
} catch (e) {
|
||||||
|
const errorMsg = e instanceof Error ? e.message : String(e)
|
||||||
|
if ((errorMsg.includes('chrome-error://chromewebdata/') || errorMsg.includes('Timeout')) && attempt < 3) {
|
||||||
|
this.bot.log(this.bot.isMobile, 'LOGIN-APP', `OAuth navigation failed (attempt ${attempt}/3), retrying...`, 'warn')
|
||||||
|
await this.bot.utils.wait(2000 * attempt)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
throw e
|
||||||
|
}
|
||||||
|
}
|
||||||
const start = Date.now()
|
const start = Date.now()
|
||||||
this.bot.log(this.bot.isMobile, 'LOGIN-APP', 'Authorizing mobile scope...')
|
this.bot.log(this.bot.isMobile, 'LOGIN-APP', 'Authorizing mobile scope...')
|
||||||
let code = ''
|
let code = ''
|
||||||
@@ -253,8 +290,24 @@ export class Login {
|
|||||||
const homeUrl = 'https://rewards.bing.com/'
|
const homeUrl = 'https://rewards.bing.com/'
|
||||||
try {
|
try {
|
||||||
const isLinux = process.platform === 'linux'
|
const isLinux = process.platform === 'linux'
|
||||||
const navigationTimeout = isLinux ? 45000 : 30000
|
const navigationTimeout = isLinux ? 60000 : 30000
|
||||||
await page.goto(homeUrl, { timeout: navigationTimeout })
|
|
||||||
|
// Retry for Linux DNS issues
|
||||||
|
for (let attempt = 1; attempt <= 2; attempt++) {
|
||||||
|
try {
|
||||||
|
await page.goto(homeUrl, { timeout: navigationTimeout })
|
||||||
|
break
|
||||||
|
} catch (e) {
|
||||||
|
const errorMsg = e instanceof Error ? e.message : String(e)
|
||||||
|
if ((errorMsg.includes('chrome-error://chromewebdata/') || errorMsg.includes('Timeout')) && attempt < 2) {
|
||||||
|
this.bot.log(this.bot.isMobile, 'LOGIN', 'Session check navigation failed, retrying...', 'warn')
|
||||||
|
await this.bot.utils.wait(2000)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
throw e
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
await page.waitForLoadState('domcontentloaded').catch(logError('LOGIN', 'DOMContentLoaded timeout', this.bot.isMobile))
|
await page.waitForLoadState('domcontentloaded').catch(logError('LOGIN', 'DOMContentLoaded timeout', this.bot.isMobile))
|
||||||
await this.bot.browser.utils.reloadBadPage(page)
|
await this.bot.browser.utils.reloadBadPage(page)
|
||||||
await this.bot.utils.wait(250)
|
await this.bot.utils.wait(250)
|
||||||
|
|||||||
Reference in New Issue
Block a user