mirror of
https://github.com/LightZirconite/Microsoft-Rewards-Bot.git
synced 2026-01-11 01:36:16 +00:00
Corrige l'indentation et améliore la lisibilité du code dans plusieurs fichiers
This commit is contained in:
@@ -80,7 +80,7 @@ export class Search extends Workers {
|
|||||||
|
|
||||||
await this.bot.browser.utils.tryDismissAllMessages(page)
|
await this.bot.browser.utils.tryDismissAllMessages(page)
|
||||||
|
|
||||||
let stagnation = 0 // consecutive searches without point progress
|
let stagnation = 0 // consecutive searches without point progress
|
||||||
|
|
||||||
const queries: string[] = []
|
const queries: string[] = []
|
||||||
// Mobile search doesn't seem to like related queries?
|
// Mobile search doesn't seem to like related queries?
|
||||||
@@ -166,7 +166,7 @@ export class Search extends Workers {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fallbackRounds++
|
fallbackRounds++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -459,7 +459,7 @@ export class MicrosoftRewardsBot {
|
|||||||
const time12Val = typeof srec['time12'] === 'string' ? String(srec['time12']) : undefined
|
const time12Val = typeof srec['time12'] === 'string' ? String(srec['time12']) : undefined
|
||||||
const time24Val = typeof srec['time24'] === 'string' ? String(srec['time24']) : undefined
|
const time24Val = typeof srec['time24'] === 'string' ? String(srec['time24']) : undefined
|
||||||
|
|
||||||
if (useAmPmVal === true) {
|
if (useAmPmVal) {
|
||||||
formatName = '12h'
|
formatName = '12h'
|
||||||
timeShown = time12Val || sched.time || '9:00 AM'
|
timeShown = time12Val || sched.time || '9:00 AM'
|
||||||
} else if (useAmPmVal === false) {
|
} else if (useAmPmVal === false) {
|
||||||
|
|||||||
@@ -359,7 +359,8 @@ export function loadConfig(): Config {
|
|||||||
candidates.push(path.join(base, name))
|
candidates.push(path.join(base, name))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let cfgPath: string | null = null
|
|
||||||
|
let cfgPath: string | null = null
|
||||||
for (const p of candidates) {
|
for (const p of candidates) {
|
||||||
try { if (fs.existsSync(p)) { cfgPath = p; break } } catch { /* ignore */ }
|
try { if (fs.existsSync(p)) { cfgPath = p; break } } catch { /* ignore */ }
|
||||||
}
|
}
|
||||||
@@ -367,11 +368,11 @@ export function loadConfig(): Config {
|
|||||||
const config = fs.readFileSync(cfgPath, 'utf-8')
|
const config = fs.readFileSync(cfgPath, 'utf-8')
|
||||||
const text = config.replace(/^\uFEFF/, '')
|
const text = config.replace(/^\uFEFF/, '')
|
||||||
const raw = JSON.parse(stripJsonComments(text))
|
const raw = JSON.parse(stripJsonComments(text))
|
||||||
const normalized = normalizeConfig(raw)
|
const normalized = normalizeConfig(raw)
|
||||||
configCache = normalized // Set as cache
|
configCache = normalized
|
||||||
configSourcePath = cfgPath
|
configSourcePath = cfgPath
|
||||||
|
|
||||||
return normalized
|
return normalized
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new Error(error as string)
|
throw new Error(error as string)
|
||||||
}
|
}
|
||||||
@@ -447,12 +448,12 @@ export async function saveFingerprintData(sessionPath: string, email: string, is
|
|||||||
await fs.promises.mkdir(sessionDir, { recursive: true })
|
await fs.promises.mkdir(sessionDir, { recursive: true })
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save fingerprint to files (write both legacy and corrected names for compatibility)
|
// Save fingerprint to files (write both legacy and corrected names for compatibility)
|
||||||
const legacy = path.join(sessionDir, `${isMobile ? 'mobile_fingerpint' : 'desktop_fingerpint'}.json`)
|
const legacy = path.join(sessionDir, `${isMobile ? 'mobile_fingerpint' : 'desktop_fingerpint'}.json`)
|
||||||
const correct = path.join(sessionDir, `${isMobile ? 'mobile_fingerprint' : 'desktop_fingerprint'}.json`)
|
const correct = path.join(sessionDir, `${isMobile ? 'mobile_fingerprint' : 'desktop_fingerprint'}.json`)
|
||||||
const payload = JSON.stringify(fingerprint)
|
const payload = JSON.stringify(fingerprint)
|
||||||
await fs.promises.writeFile(correct, payload)
|
await fs.promises.writeFile(correct, payload)
|
||||||
try { await fs.promises.writeFile(legacy, payload) } catch { /* ignore */ }
|
try { await fs.promises.writeFile(legacy, payload) } catch { /* ignore */ }
|
||||||
|
|
||||||
return sessionDir
|
return sessionDir
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ export class Retry {
|
|||||||
multiplier: 2,
|
multiplier: 2,
|
||||||
jitter: 0.2
|
jitter: 0.2
|
||||||
}
|
}
|
||||||
const merged: ConfigRetryPolicy = { ...(policy || {}) }
|
const merged: ConfigRetryPolicy = { ...(policy || {}) }
|
||||||
// normalize string durations
|
// normalize string durations
|
||||||
const util = new Util()
|
const util = new Util()
|
||||||
const parse = (v: number | string) => {
|
const parse = (v: number | string) => {
|
||||||
@@ -42,7 +42,8 @@ export class Retry {
|
|||||||
let attempt = 0
|
let attempt = 0
|
||||||
let delay = this.policy.baseDelay
|
let delay = this.policy.baseDelay
|
||||||
let lastErr: unknown
|
let lastErr: unknown
|
||||||
while (attempt < this.policy.maxAttempts) {
|
|
||||||
|
while (attempt < this.policy.maxAttempts) {
|
||||||
try {
|
try {
|
||||||
return await fn()
|
return await fn()
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user