feat: 移除CPA回调相关逻辑,固定为步骤9,更新文档以反映新流程

This commit is contained in:
祁连海
2026-04-17 23:38:47 +08:00
parent a4c7849a0f
commit 61a3bb3461
12 changed files with 1 additions and 141 deletions
-46
View File
@@ -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();
}
-7
View File
@@ -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,
};
}
-12
View File
@@ -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;
-6
View File
@@ -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。');
}
-7
View File
@@ -123,13 +123,6 @@
<button type="button" class="choice-btn" data-local-cpa-step9-mode="bypass">跳过第10步</button>
</div>
</div>
<div class="data-row" id="row-cpa-callback-mode">
<span class="data-label">CPA回调</span>
<div id="cpa-callback-mode-group" class="choice-group" role="group" aria-label="CPA 回调阶段">
<button type="button" class="choice-btn" data-cpa-callback-mode="step7">第七步回调</button>
<button type="button" class="choice-btn" data-cpa-callback-mode="step9">第九步回调</button>
</div>
</div>
<div class="data-row" id="row-sub2api-url" style="display:none;">
<span class="data-label">SUB2API</span>
<input type="text" id="input-sub2api-url" class="data-input"
-47
View File
@@ -66,8 +66,6 @@ const rowVpsPassword = document.getElementById('row-vps-password');
const inputVpsPassword = document.getElementById('input-vps-password');
const rowLocalCpaStep9Mode = document.getElementById('row-local-cpa-step9-mode');
const localCpaStep9ModeButtons = Array.from(document.querySelectorAll('[data-local-cpa-step9-mode]'));
const rowCpaCallbackMode = document.getElementById('row-cpa-callback-mode');
const cpaCallbackModeButtons = Array.from(document.querySelectorAll('[data-cpa-callback-mode]'));
const rowSub2ApiUrl = document.getElementById('row-sub2api-url');
const inputSub2ApiUrl = document.getElementById('input-sub2api-url');
const rowSub2ApiEmail = document.getElementById('row-sub2api-email');
@@ -204,7 +202,6 @@ const VERIFICATION_RESEND_COUNT_MIN = 0;
const VERIFICATION_RESEND_COUNT_MAX = 20;
const DEFAULT_VERIFICATION_RESEND_COUNT = 4;
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;
@@ -1305,7 +1302,6 @@ function collectSettingsPayload() {
vpsUrl: inputVpsUrl.value.trim(),
vpsPassword: inputVpsPassword.value,
localCpaStep9Mode: getSelectedLocalCpaStep9Mode(),
cpaCallbackMode: getSelectedCpaCallbackMode(),
sub2apiUrl: inputSub2ApiUrl.value.trim(),
sub2apiEmail: inputSub2ApiEmail.value.trim(),
sub2apiPassword: inputSub2ApiPassword.value,
@@ -1354,17 +1350,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 normalizeMail2925Mode(value = '') {
return String(value || '').trim().toLowerCase() === MAIL_2925_MODE_RECEIVE
? MAIL_2925_MODE_RECEIVE
@@ -1418,20 +1403,6 @@ function setLocalCpaStep9Mode(mode) {
});
}
function getSelectedCpaCallbackMode() {
const activeButton = cpaCallbackModeButtons.find((button) => button.classList.contains('is-active'));
return normalizeCpaCallbackMode(activeButton?.dataset.cpaCallbackMode);
}
function setCpaCallbackMode(mode) {
const resolvedMode = normalizeCpaCallbackMode(mode);
cpaCallbackModeButtons.forEach((button) => {
const active = button.dataset.cpaCallbackMode === resolvedMode;
button.classList.toggle('is-active', active);
button.setAttribute('aria-pressed', String(active));
});
}
function getSelectedMail2925Mode() {
const activeButton = mail2925ModeButtons.find((button) => button.classList.contains('is-active'));
return normalizeMail2925Mode(activeButton?.dataset.mail2925Mode);
@@ -1700,7 +1671,6 @@ function applySettingsState(state) {
inputVpsUrl.value = state?.vpsUrl || '';
inputVpsPassword.value = state?.vpsPassword || '';
setLocalCpaStep9Mode(state?.localCpaStep9Mode);
setCpaCallbackMode(state?.cpaCallbackMode);
selectPanelMode.value = state?.panelMode || 'cpa';
inputSub2ApiUrl.value = state?.sub2apiUrl || '';
inputSub2ApiEmail.value = state?.sub2apiEmail || '';
@@ -2496,7 +2466,6 @@ function updatePanelModeUI() {
rowVpsUrl.style.display = useSub2Api ? 'none' : '';
rowVpsPassword.style.display = useSub2Api ? 'none' : '';
rowLocalCpaStep9Mode.style.display = useSub2Api ? 'none' : '';
rowCpaCallbackMode.style.display = useSub2Api ? 'none' : '';
rowSub2ApiUrl.style.display = useSub2Api ? '' : 'none';
rowSub2ApiEmail.style.display = useSub2Api ? '' : 'none';
rowSub2ApiPassword.style.display = useSub2Api ? '' : 'none';
@@ -3243,18 +3212,6 @@ localCpaStep9ModeButtons.forEach((button) => {
});
});
cpaCallbackModeButtons.forEach((button) => {
button.addEventListener('click', () => {
const nextMode = button.dataset.cpaCallbackMode;
if (getSelectedCpaCallbackMode() === normalizeCpaCallbackMode(nextMode)) {
return;
}
setCpaCallbackMode(nextMode);
markSettingsDirty(true);
saveSettings({ silent: true }).catch(() => { });
});
});
hotmailServiceModeButtons.forEach((button) => {
button.addEventListener('click', () => {
if (button.disabled) {
@@ -4013,9 +3970,6 @@ chrome.runtime.onMessage.addListener((message, _sender, sendResponse) => {
if (message.payload.localCpaStep9Mode !== undefined) {
setLocalCpaStep9Mode(message.payload.localCpaStep9Mode);
}
if (message.payload.cpaCallbackMode !== undefined) {
setCpaCallbackMode(message.payload.cpaCallbackMode);
}
if (message.payload.oauthUrl !== undefined) {
displayOauthUrl.textContent = message.payload.oauthUrl || '等待中...';
displayOauthUrl.classList.toggle('has-value', Boolean(message.payload.oauthUrl));
@@ -4207,7 +4161,6 @@ initHotmailListExpandedState();
updateSaveButtonState();
updateConfigMenuControls();
setLocalCpaStep9Mode(DEFAULT_LOCAL_CPA_STEP9_MODE);
setCpaCallbackMode(DEFAULT_CPA_CALLBACK_MODE);
setMail2925Mode(DEFAULT_MAIL_2925_MODE);
initializeReleaseInfo().catch((err) => {
console.error('Failed to initialize release info:', err);
-3
View File
@@ -143,9 +143,6 @@ async function getTabId() {
return 1;
}
function shouldSkipLoginVerificationForCpaCallback() {
return false;
}
async function invalidateDownstreamAfterStepRestart(step, options = {}) {
events.invalidations.push({ step, options });
-3
View File
@@ -114,9 +114,6 @@ async function executeStepAndWait(step) {
async function getTabId() {
return 1;
}
function shouldSkipLoginVerificationForCpaCallback() {
return false;
}
async function invalidateDownstreamAfterStepRestart(step, options = {}) {
events.invalidations.push({ step, options });
}
@@ -71,10 +71,6 @@ const PERSISTED_SETTING_DEFAULTS = {
};
function normalizePanelMode(value) { return value === 'sub2api' ? 'sub2api' : 'cpa'; }
function normalizeLocalCpaStep9Mode(value) { return value === 'bypass' ? 'bypass' : 'submit'; }
function normalizeCpaCallbackMode(value) {
if (value === 'step7' || value === 'step6') return 'step7';
return value === 'step9' || value === 'step8' ? 'step9' : 'step9';
}
function normalizeAutoRunFallbackThreadIntervalMinutes(value) { return Number(value) || 0; }
function normalizeAutoRunDelayMinutes(value) { return Number(value) || 30; }
function normalizeAutoStepDelaySeconds(value) { return value == null || value === '' ? null : Number(value); }
@@ -61,8 +61,6 @@ test('step 7 retries up to configured limit and then fails', async () => {
message: '当前仍停留在邮箱页。',
};
},
shouldSkipLoginVerificationForCpaCallback: () => false,
skipLoginVerificationStepsForCpaCallback: async () => {},
STEP6_MAX_ATTEMPTS: 3,
throwIfStopped: () => {},
});
@@ -105,8 +103,6 @@ test('step 7 starts a new oauth timeout window for each refreshed oauth url', as
step6Outcome: 'success',
usedTimeoutMs: options.timeoutMs,
}),
shouldSkipLoginVerificationForCpaCallback: () => false,
skipLoginVerificationStepsForCpaCallback: async () => {},
startOAuthFlowTimeoutWindow: async (payload) => {
events.startedWindows.push(payload);
},
-2
View File
@@ -55,7 +55,6 @@ test('step 8 submits login verification directly without replaying step 7', asyn
reuseOrCreateTab: async () => {},
setState: async () => {},
setStepStatus: async () => {},
shouldSkipLoginVerificationForCpaCallback: () => false,
shouldUseCustomRegistrationEmail: () => false,
sleepWithStop: async (ms) => {
calls.sleep.push(ms);
@@ -123,7 +122,6 @@ test('step 8 disables resend interval for 2925 mailbox polling', async () => {
reuseOrCreateTab: async () => {},
setState: async () => {},
setStepStatus: async () => {},
shouldSkipLoginVerificationForCpaCallback: () => false,
shouldUseCustomRegistrationEmail: () => false,
sleepWithStop: async () => {},
STANDARD_MAIL_VERIFICATION_RESEND_INTERVAL_MS: 25000,
+1
View File
@@ -300,6 +300,7 @@
4. 确保真正进入验证码页
5. 如果未进入验证码页,则按可恢复逻辑最多重试 3 次
6. 自动运行一旦进入步骤 7 之后的链路,若后续步骤报错且认证页未进入 `https://auth.openai.com/add-phone`,则统一回到步骤 7 重新开始授权流程
7. CPA 回调阶段固定为步骤 9,不再支持“第七步回调”跳过步骤 7/8
### Step 8