From 61a3bb3461a2039cec8934bf8534ac1e1cc48ca6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A5=81=E8=BF=9E=E6=B5=B7?= <2825305047@qq.com> Date: Fri, 17 Apr 2026 23:38:47 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=A7=BB=E9=99=A4CPA=E5=9B=9E=E8=B0=83?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E9=80=BB=E8=BE=91=EF=BC=8C=E5=9B=BA=E5=AE=9A?= =?UTF-8?q?=E4=B8=BA=E6=AD=A5=E9=AA=A49=EF=BC=8C=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E6=96=87=E6=A1=A3=E4=BB=A5=E5=8F=8D=E6=98=A0=E6=96=B0=E6=B5=81?= =?UTF-8?q?=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- background.js | 46 ------------------ background/navigation-utils.js | 7 --- background/steps/fetch-login-code.js | 12 ----- background/steps/oauth-login.js | 6 --- sidepanel/sidepanel.html | 7 --- sidepanel/sidepanel.js | 47 ------------------- tests/auto-run-step4-restart.test.js | 3 -- tests/auto-run-step6-restart.test.js | 3 -- ...ackground-account-history-settings.test.js | 4 -- tests/background-step6-retry-limit.test.js | 4 -- tests/background-step7-recovery.test.js | 2 - 项目完整链路说明.md | 1 + 12 files changed, 1 insertion(+), 141 deletions(-) diff --git a/background.js b/background.js index e52b7d4..f7bd807 100644 --- a/background.js +++ b/background.js @@ -158,7 +158,6 @@ const DEFAULT_VERIFICATION_RESEND_COUNT = 4; const LEGACY_AUTO_STEP_DELAY_KEYS = ['autoStepRandomDelayMinSeconds', 'autoStepRandomDelayMaxSeconds']; const LEGACY_VERIFICATION_RESEND_COUNT_KEYS = ['signupVerificationResendCount', 'loginVerificationResendCount']; const DEFAULT_LOCAL_CPA_STEP9_MODE = 'submit'; -const DEFAULT_CPA_CALLBACK_MODE = 'step9'; const MAIL_2925_MODE_PROVIDE = 'provide'; const MAIL_2925_MODE_RECEIVE = 'receive'; const DEFAULT_MAIL_2925_MODE = MAIL_2925_MODE_PROVIDE; @@ -212,7 +211,6 @@ const PERSISTED_SETTING_DEFAULTS = { vpsUrl: '', vpsPassword: '', localCpaStep9Mode: DEFAULT_LOCAL_CPA_STEP9_MODE, - cpaCallbackMode: DEFAULT_CPA_CALLBACK_MODE, sub2apiUrl: DEFAULT_SUB2API_URL, sub2apiEmail: '', sub2apiPassword: '', @@ -688,17 +686,6 @@ function normalizeLocalCpaStep9Mode(value = '') { : DEFAULT_LOCAL_CPA_STEP9_MODE; } -function normalizeCpaCallbackMode(value = '') { - const normalized = String(value || '').trim().toLowerCase(); - if (normalized === 'step7' || normalized === 'step6') { - return 'step7'; - } - if (normalized === 'step9' || normalized === 'step8') { - return 'step9'; - } - return DEFAULT_CPA_CALLBACK_MODE; -} - function normalizeCloudflareDomain(rawValue = '') { let value = String(rawValue || '').trim().toLowerCase(); if (!value) return ''; @@ -833,8 +820,6 @@ function normalizePersistentSettingValue(key, value) { return String(value || ''); case 'localCpaStep9Mode': return normalizeLocalCpaStep9Mode(value); - case 'cpaCallbackMode': - return normalizeCpaCallbackMode(value); case 'sub2apiUrl': return String(value || '').trim(); case 'sub2apiEmail': @@ -3585,14 +3570,6 @@ function shouldBypassStep9ForLocalCpa(state) { && isLocalCpaUrl(state?.vpsUrl); } -function shouldSkipLoginVerificationForCpaCallback(state) { - if (typeof navigationUtils !== 'undefined' && navigationUtils?.shouldSkipLoginVerificationForCpaCallback) { - return navigationUtils.shouldSkipLoginVerificationForCpaCallback(state); - } - return getPanelMode(state) === 'cpa' - && normalizeCpaCallbackMode(state?.cpaCallbackMode) === 'step7'; -} - function matchesSourceUrlFamily(source, candidateUrl, referenceUrl) { if (typeof navigationUtils !== 'undefined' && navigationUtils?.matchesSourceUrlFamily) { return navigationUtils.matchesSourceUrlFamily(source, candidateUrl, referenceUrl); @@ -3819,7 +3796,6 @@ function isRetryableContentScriptTransportError(error) { const navigationUtils = self.MultiPageBackgroundNavigationUtils?.createNavigationUtils({ DEFAULT_SUB2API_URL, - normalizeCpaCallbackMode, normalizeLocalCpaStep9Mode, }); @@ -5501,10 +5477,6 @@ async function runAutoSequenceFromStep(startStep, context = {}) { try { await executeStepAndWait(step, AUTO_STEP_DELAYS[step]); const latestState = await getState(); - if (step === FINAL_OAUTH_CHAIN_START_STEP && shouldSkipLoginVerificationForCpaCallback(latestState)) { - step = 9; - continue; - } step += 1; } catch (err) { if (isStopError(err)) { @@ -5816,8 +5788,6 @@ const step7Executor = self.MultiPageBackgroundStep7?.createStep7Executor({ refreshOAuthUrlBeforeStep6, reuseOrCreateTab, sendToContentScriptResilient, - shouldSkipLoginVerificationForCpaCallback, - skipLoginVerificationStepsForCpaCallback, startOAuthFlowTimeoutWindow, STEP6_MAX_ATTEMPTS, throwIfStopped, @@ -5843,7 +5813,6 @@ const step8Executor = self.MultiPageBackgroundStep8?.createStep8Executor({ reuseOrCreateTab, setState, setStepStatus, - shouldSkipLoginVerificationForCpaCallback, shouldUseCustomRegistrationEmail, sleepWithStop, STANDARD_MAIL_VERIFICATION_RESEND_INTERVAL_MS, @@ -6466,21 +6435,6 @@ async function ensureStep8VerificationPageReady(options = {}) { throw new Error(`当前未进入登录验证码页面,请先重新完成步骤 7。当前状态:${stateLabel}.${urlPart}`.trim()); } -async function skipLoginVerificationStepsForCpaCallback() { - await setState({ - lastLoginCode: null, - loginVerificationRequestedAt: null, - oauthFlowDeadlineAt: null, - }); - await setStepStatus(7, 'skipped'); - await addLog('步骤 7:当前已选择“第七步回调”,直接跳过步骤 7、8。', 'warn'); - const latestState = await getState(); - if (!isStepDoneStatus(latestState.stepStatuses?.[8])) { - await setStepStatus(8, 'skipped'); - await addLog('步骤 8:当前已选择“第七步回调”,本轮无需获取登录验证码。', 'warn'); - } -} - async function executeStep6() { return step6Executor.executeStep6(); } diff --git a/background/navigation-utils.js b/background/navigation-utils.js index 067e08c..2c7b793 100644 --- a/background/navigation-utils.js +++ b/background/navigation-utils.js @@ -4,7 +4,6 @@ function createNavigationUtils(deps = {}) { const { DEFAULT_SUB2API_URL, - normalizeCpaCallbackMode, normalizeLocalCpaStep9Mode, } = deps; @@ -90,11 +89,6 @@ && isLocalCpaUrl(state?.vpsUrl); } - function shouldSkipLoginVerificationForCpaCallback(state) { - return getPanelMode(state) === 'cpa' - && normalizeCpaCallbackMode(state?.cpaCallbackMode) === 'step7'; - } - function matchesSourceUrlFamily(source, candidateUrl, referenceUrl) { const candidate = parseUrlSafely(candidateUrl); if (!candidate) return false; @@ -169,7 +163,6 @@ normalizeSub2ApiUrl, parseUrlSafely, shouldBypassStep9ForLocalCpa, - shouldSkipLoginVerificationForCpaCallback, }; } diff --git a/background/steps/fetch-login-code.js b/background/steps/fetch-login-code.js index cd5832d..e0dd7ec 100644 --- a/background/steps/fetch-login-code.js +++ b/background/steps/fetch-login-code.js @@ -22,7 +22,6 @@ reuseOrCreateTab, setState, setStepStatus, - shouldSkipLoginVerificationForCpaCallback, shouldUseCustomRegistrationEmail, sleepWithStop, STANDARD_MAIL_VERIFICATION_RESEND_INTERVAL_MS, @@ -127,17 +126,6 @@ } async function executeStep8(state) { - if (shouldSkipLoginVerificationForCpaCallback(state)) { - await setState({ - lastLoginCode: null, - loginVerificationRequestedAt: null, - oauthFlowDeadlineAt: null, - }); - await setStepStatus(8, 'skipped'); - await addLog('步骤 8:当前已选择“第七步回调”,本轮无需获取登录验证码。', 'warn'); - return; - } - let currentState = state; let mailPollingAttempt = 1; let lastMailPollingError = null; diff --git a/background/steps/oauth-login.js b/background/steps/oauth-login.js index 69044c0..ce729ad 100644 --- a/background/steps/oauth-login.js +++ b/background/steps/oauth-login.js @@ -14,18 +14,12 @@ refreshOAuthUrlBeforeStep6, reuseOrCreateTab, sendToContentScriptResilient, - shouldSkipLoginVerificationForCpaCallback, - skipLoginVerificationStepsForCpaCallback, startOAuthFlowTimeoutWindow, STEP6_MAX_ATTEMPTS, throwIfStopped, } = deps; async function executeStep7(state) { - if (shouldSkipLoginVerificationForCpaCallback(state)) { - await skipLoginVerificationStepsForCpaCallback(); - return; - } if (!state.email) { throw new Error('缺少邮箱地址,请先完成步骤 3。'); } diff --git a/sidepanel/sidepanel.html b/sidepanel/sidepanel.html index 4a8d167..47705e4 100644 --- a/sidepanel/sidepanel.html +++ b/sidepanel/sidepanel.html @@ -123,13 +123,6 @@ -