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:
@@ -9,6 +9,7 @@
|
||||
confirmCustomVerificationStepBypass,
|
||||
ensureStep7VerificationPageReady,
|
||||
executeStep6,
|
||||
getPanelMode,
|
||||
getMailConfig,
|
||||
getState,
|
||||
getTabId,
|
||||
@@ -77,18 +78,45 @@
|
||||
}
|
||||
}
|
||||
|
||||
const shouldRefreshOAuthBeforeSubmit = getPanelMode(state) === 'cpa';
|
||||
let step6ReplayCompleted = false;
|
||||
|
||||
await resolveVerificationStep(7, state, mail, {
|
||||
filterAfterTimestamp: mail.provider === HOTMAIL_PROVIDER ? undefined : Math.max(0, stepStartedAt - 60000),
|
||||
requestFreshCodeFirst: false,
|
||||
resendIntervalMs: mail.provider === HOTMAIL_PROVIDER ? 0 : STANDARD_MAIL_VERIFICATION_RESEND_INTERVAL_MS,
|
||||
resendIntervalMs: (mail.provider === HOTMAIL_PROVIDER || mail.provider === '2925')
|
||||
? 0
|
||||
: STANDARD_MAIL_VERIFICATION_RESEND_INTERVAL_MS,
|
||||
beforeSubmit: shouldRefreshOAuthBeforeSubmit ? async (result) => {
|
||||
if (step6ReplayCompleted) {
|
||||
return;
|
||||
}
|
||||
|
||||
step6ReplayCompleted = true;
|
||||
await addLog(`步骤 7:已拿到登录验证码 ${result.code},先刷新 CPA OAuth 链接并重走步骤 6,再回填验证码。`, 'warn');
|
||||
await rerunStep6ForStep7Recovery({
|
||||
logMessage: '步骤 7:正在重新获取最新 CPA OAuth 链接,并快速重走步骤 6...',
|
||||
skipPreLoginCleanup: true,
|
||||
postStepDelayMs: 1200,
|
||||
});
|
||||
await ensureStep7VerificationPageReady();
|
||||
await addLog('步骤 7:登录验证码页面已重新就绪,开始回填刚才获取到的验证码。', 'info');
|
||||
} : undefined,
|
||||
});
|
||||
}
|
||||
|
||||
async function rerunStep6ForStep7Recovery() {
|
||||
async function rerunStep6ForStep7Recovery(options = {}) {
|
||||
const {
|
||||
logMessage = '步骤 7:正在回到步骤 6,重新发起登录验证码流程...',
|
||||
skipPreLoginCleanup = false,
|
||||
postStepDelayMs = 3000,
|
||||
} = options;
|
||||
const currentState = await getState();
|
||||
await addLog('步骤 7:正在回到步骤 6,重新发起登录验证码流程...', 'warn');
|
||||
await executeStep6(currentState);
|
||||
await sleepWithStop(3000);
|
||||
await addLog(logMessage, 'warn');
|
||||
await executeStep6(currentState, { skipPreLoginCleanup });
|
||||
if (postStepDelayMs > 0) {
|
||||
await sleepWithStop(postStepDelayMs);
|
||||
}
|
||||
}
|
||||
|
||||
async function executeStep7(state) {
|
||||
|
||||
Reference in New Issue
Block a user