mirror of
https://github.com/LightZirconite/Microsoft-Rewards-Bot.git
synced 2026-01-11 17:56:15 +00:00
Improved error handling and added protection against race conditions in the bot controller. Extracted Microsoft domain verification for better maintainability. Added support for custom activity managers and improved documentation.
This commit is contained in:
@@ -33,6 +33,18 @@ export class AccountCreator {
|
||||
await this.page.waitForTimeout(Math.floor(delay))
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper: Check if email domain is a Microsoft-managed domain
|
||||
* Extracted to avoid duplication and improve maintainability
|
||||
*/
|
||||
private isMicrosoftDomain(domain: string | undefined): boolean {
|
||||
if (!domain) return false
|
||||
const lowerDomain = domain.toLowerCase()
|
||||
return lowerDomain === 'outlook.com' ||
|
||||
lowerDomain === 'hotmail.com' ||
|
||||
lowerDomain === 'outlook.fr'
|
||||
}
|
||||
|
||||
/**
|
||||
* UTILITY: Find first visible element from list of selectors
|
||||
* Reserved for future use - simplifies selector fallback logic
|
||||
@@ -950,12 +962,16 @@ export class AccountCreator {
|
||||
await emailInput.fill(newEmail)
|
||||
await this.humanDelay(1200, 2500)
|
||||
|
||||
// SMART VERIFICATION: Microsoft may separate domain
|
||||
// SMART VERIFICATION: Microsoft may separate domain for managed email providers
|
||||
const inputValue = await emailInput.inputValue().catch(() => '')
|
||||
const emailUsername = newEmail.split('@')[0]
|
||||
const emailDomain = newEmail.split('@')[1]
|
||||
|
||||
if (inputValue === newEmail || (inputValue === emailUsername && (emailDomain === 'outlook.com' || emailDomain === 'hotmail.com' || emailDomain === 'outlook.fr'))) {
|
||||
// Check if input matches full email OR username only (when domain is Microsoft-managed)
|
||||
const isFullMatch = inputValue === newEmail
|
||||
const isUsernameOnlyMatch = inputValue === emailUsername && this.isMicrosoftDomain(emailDomain)
|
||||
|
||||
if (isFullMatch || isUsernameOnlyMatch) {
|
||||
return true
|
||||
} else {
|
||||
throw new Error('Email retry input value not verified')
|
||||
@@ -1024,12 +1040,16 @@ export class AccountCreator {
|
||||
await emailInput.fill(newEmail)
|
||||
await this.humanDelay(1200, 2500)
|
||||
|
||||
// SMART VERIFICATION: Microsoft may separate domain
|
||||
// SMART VERIFICATION: Microsoft may separate domain for managed email providers
|
||||
const inputValue = await emailInput.inputValue().catch(() => '')
|
||||
const emailUsername = newEmail.split('@')[0]
|
||||
const emailDomain = newEmail.split('@')[1]
|
||||
|
||||
if (inputValue === newEmail || (inputValue === emailUsername && (emailDomain === 'outlook.com' || emailDomain === 'hotmail.com' || emailDomain === 'outlook.fr'))) {
|
||||
// Check if input matches full email OR username only (when domain is Microsoft-managed)
|
||||
const isFullMatch = inputValue === newEmail
|
||||
const isUsernameOnlyMatch = inputValue === emailUsername && this.isMicrosoftDomain(emailDomain)
|
||||
|
||||
if (isFullMatch || isUsernameOnlyMatch) {
|
||||
return true
|
||||
} else {
|
||||
throw new Error('Email auto-retry input value not verified')
|
||||
|
||||
Reference in New Issue
Block a user