mirror of
https://github.com/LightZirconite/Microsoft-Rewards-Bot.git
synced 2026-01-09 17:06:15 +00:00
Added specific arguments for Linux and Windows machines
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -20,3 +20,4 @@ accounts.main.jsonc
|
||||
.update-extract/
|
||||
.update-happened
|
||||
.update-restart-count
|
||||
src/config.jsonc
|
||||
|
||||
@@ -94,24 +94,39 @@ class Browser {
|
||||
'--no-first-run',
|
||||
'--no-default-browser-check',
|
||||
'--no-zygote',
|
||||
'--single-process',
|
||||
// ANTI-DETECTION: Make WebDriver undetectable
|
||||
'--enable-features=NetworkService,NetworkServiceInProcess'
|
||||
]
|
||||
|
||||
// Linux stability fixes
|
||||
const linuxStabilityArgs = isLinux ? [
|
||||
// Platform-specific stability fixes
|
||||
// CRITICAL: --single-process is unstable on Windows and causes context closure
|
||||
const platformStabilityArgs = isLinux ? [
|
||||
'--single-process', // Safe on Linux with proper memory management
|
||||
'--disable-dev-shm-usage',
|
||||
'--disable-software-rasterizer',
|
||||
'--disable-http-cache',
|
||||
'--disk-cache-size=1'
|
||||
] : []
|
||||
] : [
|
||||
// Windows-specific stability (avoid --single-process which crashes Chromium context)
|
||||
'--disable-background-networking',
|
||||
'--disable-preconnect',
|
||||
'--disable-web-resources',
|
||||
'--disable-component-extensions-with-background-pages',
|
||||
'--disable-translate',
|
||||
'--disable-sync-on-cellular',
|
||||
'--disable-device-discovery-notifications',
|
||||
'--disable-default-language',
|
||||
'--disable-print-preview'
|
||||
]
|
||||
|
||||
// CRITICAL: Windows needs longer timeout (120s) due to slower context initialization
|
||||
const launchTimeout = isLinux ? 90000 : 120000
|
||||
|
||||
browser = await playwright.chromium.launch({
|
||||
headless,
|
||||
...(proxyConfig && { proxy: proxyConfig }),
|
||||
args: [...baseArgs, ...linuxStabilityArgs],
|
||||
timeout: isLinux ? 90000 : 60000
|
||||
args: [...baseArgs, ...platformStabilityArgs],
|
||||
timeout: launchTimeout
|
||||
})
|
||||
} catch (e: unknown) {
|
||||
const msg = (e instanceof Error ? e.message : String(e))
|
||||
|
||||
@@ -88,7 +88,7 @@
|
||||
},
|
||||
// === BROWSER ===
|
||||
"browser": {
|
||||
"headless": false,
|
||||
"headless": true,
|
||||
"globalTimeout": "30s"
|
||||
},
|
||||
"fingerprinting": {
|
||||
|
||||
@@ -46,6 +46,7 @@ const DEFAULT_TIMEOUTS = {
|
||||
rewardsPortalCheck: 8000,
|
||||
navigationTimeout: 30000,
|
||||
navigationTimeoutLinux: 60000,
|
||||
navigationTimeoutWindows: 90000, // Windows is slower at initializing contexts (issue: context closure)
|
||||
bingVerificationMaxIterations: 10,
|
||||
bingVerificationMaxIterationsMobile: 8
|
||||
} as const
|
||||
@@ -121,7 +122,11 @@ export class Login {
|
||||
maxAttempts = 3
|
||||
): Promise<{ success: boolean; recoveryUsed: boolean }> {
|
||||
const isLinux = process.platform === 'linux'
|
||||
const navigationTimeout = isLinux ? DEFAULT_TIMEOUTS.navigationTimeoutLinux : DEFAULT_TIMEOUTS.navigationTimeout
|
||||
const isWindows = process.platform === 'win32'
|
||||
// CRITICAL FIX: Windows needs 90s timeout to avoid "Target page, context or browser has been closed"
|
||||
const navigationTimeout = isWindows ? DEFAULT_TIMEOUTS.navigationTimeoutWindows :
|
||||
isLinux ? DEFAULT_TIMEOUTS.navigationTimeoutLinux :
|
||||
DEFAULT_TIMEOUTS.navigationTimeout
|
||||
|
||||
let navigationSucceeded = false
|
||||
let recoveryUsed = false
|
||||
|
||||
Reference in New Issue
Block a user