mirror of
https://github.com/LightZirconite/Microsoft-Rewards-Bot.git
synced 2026-01-10 17:26:17 +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-extract/
|
||||||
.update-happened
|
.update-happened
|
||||||
.update-restart-count
|
.update-restart-count
|
||||||
|
src/config.jsonc
|
||||||
|
|||||||
@@ -94,24 +94,39 @@ class Browser {
|
|||||||
'--no-first-run',
|
'--no-first-run',
|
||||||
'--no-default-browser-check',
|
'--no-default-browser-check',
|
||||||
'--no-zygote',
|
'--no-zygote',
|
||||||
'--single-process',
|
|
||||||
// ANTI-DETECTION: Make WebDriver undetectable
|
// ANTI-DETECTION: Make WebDriver undetectable
|
||||||
'--enable-features=NetworkService,NetworkServiceInProcess'
|
'--enable-features=NetworkService,NetworkServiceInProcess'
|
||||||
]
|
]
|
||||||
|
|
||||||
// Linux stability fixes
|
// Platform-specific stability fixes
|
||||||
const linuxStabilityArgs = isLinux ? [
|
// 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-dev-shm-usage',
|
||||||
'--disable-software-rasterizer',
|
'--disable-software-rasterizer',
|
||||||
'--disable-http-cache',
|
'--disable-http-cache',
|
||||||
'--disk-cache-size=1'
|
'--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({
|
browser = await playwright.chromium.launch({
|
||||||
headless,
|
headless,
|
||||||
...(proxyConfig && { proxy: proxyConfig }),
|
...(proxyConfig && { proxy: proxyConfig }),
|
||||||
args: [...baseArgs, ...linuxStabilityArgs],
|
args: [...baseArgs, ...platformStabilityArgs],
|
||||||
timeout: isLinux ? 90000 : 60000
|
timeout: launchTimeout
|
||||||
})
|
})
|
||||||
} catch (e: unknown) {
|
} catch (e: unknown) {
|
||||||
const msg = (e instanceof Error ? e.message : String(e))
|
const msg = (e instanceof Error ? e.message : String(e))
|
||||||
|
|||||||
@@ -88,7 +88,7 @@
|
|||||||
},
|
},
|
||||||
// === BROWSER ===
|
// === BROWSER ===
|
||||||
"browser": {
|
"browser": {
|
||||||
"headless": false,
|
"headless": true,
|
||||||
"globalTimeout": "30s"
|
"globalTimeout": "30s"
|
||||||
},
|
},
|
||||||
"fingerprinting": {
|
"fingerprinting": {
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ const DEFAULT_TIMEOUTS = {
|
|||||||
rewardsPortalCheck: 8000,
|
rewardsPortalCheck: 8000,
|
||||||
navigationTimeout: 30000,
|
navigationTimeout: 30000,
|
||||||
navigationTimeoutLinux: 60000,
|
navigationTimeoutLinux: 60000,
|
||||||
|
navigationTimeoutWindows: 90000, // Windows is slower at initializing contexts (issue: context closure)
|
||||||
bingVerificationMaxIterations: 10,
|
bingVerificationMaxIterations: 10,
|
||||||
bingVerificationMaxIterationsMobile: 8
|
bingVerificationMaxIterationsMobile: 8
|
||||||
} as const
|
} as const
|
||||||
@@ -121,7 +122,11 @@ export class Login {
|
|||||||
maxAttempts = 3
|
maxAttempts = 3
|
||||||
): Promise<{ success: boolean; recoveryUsed: boolean }> {
|
): Promise<{ success: boolean; recoveryUsed: boolean }> {
|
||||||
const isLinux = process.platform === 'linux'
|
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 navigationSucceeded = false
|
||||||
let recoveryUsed = false
|
let recoveryUsed = false
|
||||||
|
|||||||
Reference in New Issue
Block a user