feat: add account run history module and logging functionality
- Implemented `background/account-run-history.js` to persist account run results (success, failure, stop) in `chrome.storage.local` and log to a text file when the local Hotmail helper is enabled. - Enhanced `background/auto-run-controller.js` and `background/message-router.js` to utilize the new account run record functionality. - Updated steps in `background/steps/fetch-login-code.js`, `background/steps/fetch-signup-code.js`, and `background/steps/oauth-login.js` to handle retries and logging appropriately. - Introduced tests for account run history and step retry limits to ensure functionality and reliability. - Modified documentation to reflect new features and changes in behavior for specific providers (e.g., 2925).
This commit is contained in:
@@ -15,6 +15,8 @@
|
||||
HOTMAIL_PROVIDER,
|
||||
isStopError,
|
||||
LUCKMAIL_PROVIDER,
|
||||
MAIL_2925_VERIFICATION_INTERVAL_MS,
|
||||
MAIL_2925_VERIFICATION_MAX_ATTEMPTS,
|
||||
pollCloudflareTempEmailVerificationCode,
|
||||
pollHotmailVerificationCode,
|
||||
pollLuckmailVerificationCode,
|
||||
@@ -62,14 +64,15 @@
|
||||
}
|
||||
|
||||
function getVerificationPollPayload(step, state, overrides = {}) {
|
||||
const is2925Provider = state?.mailProvider === '2925';
|
||||
if (step === 4) {
|
||||
return {
|
||||
filterAfterTimestamp: getHotmailVerificationRequestTimestamp(4, state),
|
||||
senderFilters: ['openai', 'noreply', 'verify', 'auth', 'duckduckgo', 'forward'],
|
||||
subjectFilters: ['verify', 'verification', 'code', '验证码', 'confirm'],
|
||||
targetEmail: state.email,
|
||||
maxAttempts: 5,
|
||||
intervalMs: 3000,
|
||||
maxAttempts: is2925Provider ? MAIL_2925_VERIFICATION_MAX_ATTEMPTS : 5,
|
||||
intervalMs: is2925Provider ? MAIL_2925_VERIFICATION_INTERVAL_MS : 3000,
|
||||
...overrides,
|
||||
};
|
||||
}
|
||||
@@ -79,8 +82,8 @@
|
||||
senderFilters: ['openai', 'noreply', 'verify', 'auth', 'chatgpt', 'duckduckgo', 'forward'],
|
||||
subjectFilters: ['verify', 'verification', 'code', '验证码', 'confirm', 'login'],
|
||||
targetEmail: state.email,
|
||||
maxAttempts: 5,
|
||||
intervalMs: 3000,
|
||||
maxAttempts: is2925Provider ? MAIL_2925_VERIFICATION_MAX_ATTEMPTS : 5,
|
||||
intervalMs: is2925Provider ? MAIL_2925_VERIFICATION_INTERVAL_MS : 3000,
|
||||
...overrides,
|
||||
};
|
||||
}
|
||||
@@ -368,6 +371,9 @@
|
||||
const hotmailPollConfig = mail.provider === HOTMAIL_PROVIDER
|
||||
? getHotmailVerificationPollConfig(step)
|
||||
: null;
|
||||
const beforeSubmit = typeof options.beforeSubmit === 'function'
|
||||
? options.beforeSubmit
|
||||
: null;
|
||||
const ignorePersistedLastCode = Boolean(hotmailPollConfig?.ignorePersistedLastCode);
|
||||
if (state[stateKey] && !ignorePersistedLastCode) {
|
||||
rejectedCodes.add(state[stateKey]);
|
||||
@@ -431,6 +437,14 @@
|
||||
|
||||
throwIfStopped();
|
||||
await addLog(`步骤 ${step}:已获取${getVerificationCodeLabel(step)}验证码:${result.code}`);
|
||||
if (beforeSubmit) {
|
||||
await beforeSubmit(result, {
|
||||
attempt,
|
||||
rejectedCodes: new Set(rejectedCodes),
|
||||
filterAfterTimestamp: nextFilterAfterTimestamp ?? undefined,
|
||||
lastResendAt,
|
||||
});
|
||||
}
|
||||
throwIfStopped();
|
||||
const submitResult = await submitVerificationCode(step, result.code);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user