From 89854f17f2c9a63da222d8af7642c0cdbb0d3a3e Mon Sep 17 00:00:00 2001 From: QLHazyCoder <2825305047@qq.com> Date: Tue, 14 Apr 2026 16:20:58 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=87=AA=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E9=82=AE=E7=AE=B1=E4=BD=8D=E7=BD=AE=E5=8F=8A=E6=95=B4=E4=BD=93?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- background.js | 58 +++++++++++++++- sidepanel/sidepanel.css | 15 ++++ sidepanel/sidepanel.html | 3 +- sidepanel/sidepanel.js | 143 +++++++++++++++++++++++++++++---------- 4 files changed, 180 insertions(+), 39 deletions(-) diff --git a/background.js b/background.js index b293560..cd30150 100644 --- a/background.js +++ b/background.js @@ -230,6 +230,7 @@ function normalizePanelMode(value = '') { function normalizeMailProvider(value = '') { const normalized = String(value || '').trim().toLowerCase(); switch (normalized) { + case 'custom': case HOTMAIL_PROVIDER: case '163': case '163-vip': @@ -644,6 +645,13 @@ function isHotmailProvider(stateOrProvider) { return provider === HOTMAIL_PROVIDER; } +function isCustomMailProvider(stateOrProvider) { + const provider = typeof stateOrProvider === 'string' + ? stateOrProvider + : stateOrProvider?.mailProvider; + return provider === 'custom'; +} + async function syncHotmailAccounts(accounts) { const normalized = normalizeHotmailAccounts(accounts); await setPersistentSettings({ hotmailAccounts: normalized }); @@ -1272,9 +1280,10 @@ function isGeneratedAliasProvider(provider) { } function shouldUseCustomRegistrationEmail(state = {}) { - return !isHotmailProvider(state) - && !isGeneratedAliasProvider(state.mailProvider) - && normalizeEmailGenerator(state.emailGenerator) === 'custom'; + return isCustomMailProvider(state) + || (!isHotmailProvider(state) + && !isGeneratedAliasProvider(state.mailProvider) + && normalizeEmailGenerator(state.emailGenerator) === 'custom'); } function buildGeneratedAliasEmail(state) { @@ -4667,6 +4676,9 @@ async function executeStep3(state) { function getMailConfig(state) { const provider = state.mailProvider || 'qq'; + if (provider === 'custom') { + return { provider: 'custom', label: '自定义邮箱' }; + } if (provider === HOTMAIL_PROVIDER) { return { provider: HOTMAIL_PROVIDER, label: 'Hotmail(远程/本地)' }; } @@ -4728,6 +4740,36 @@ function getVerificationCodeLabel(step) { return step === 4 ? '注册' : '登录'; } +async function confirmCustomVerificationStepBypass(step) { + const verificationLabel = getVerificationCodeLabel(step); + await addLog(`步骤 ${step}:当前为自定义邮箱模式,请手动在页面中输入${verificationLabel}验证码并进入下一页面。`, 'warn'); + + let response = null; + try { + response = await chrome.runtime.sendMessage({ + type: 'REQUEST_CUSTOM_VERIFICATION_BYPASS_CONFIRMATION', + payload: { step }, + }); + } catch { + throw new Error(`步骤 ${step}:无法打开确认弹窗,请先保持侧边栏打开后重试。`); + } + + if (response?.error) { + throw new Error(response.error); + } + if (!response?.confirmed) { + throw new Error(`步骤 ${step}:已取消手动${verificationLabel}验证码确认。`); + } + + await setState({ + lastEmailTimestamp: null, + signupVerificationRequestedAt: null, + loginVerificationRequestedAt: null, + }); + await setStepStatus(step, 'skipped'); + await addLog(`步骤 ${step}:已确认手动完成${verificationLabel}验证码输入,当前步骤已跳过。`, 'warn'); +} + function getVerificationPollPayload(step, state, overrides = {}) { if (step === 4) { return { @@ -5004,6 +5046,11 @@ async function executeStep4(state) { return; } + if (shouldUseCustomRegistrationEmail(state)) { + await confirmCustomVerificationStepBypass(4); + return; + } + throwIfStopped(); if (mail.provider === HOTMAIL_PROVIDER) { await addLog(`步骤 4:正在通过 ${mail.label} 轮询验证码...`); @@ -5134,6 +5181,11 @@ async function runStep7Attempt(state) { throw new Error(prepareResult.error); } + if (shouldUseCustomRegistrationEmail(state)) { + await confirmCustomVerificationStepBypass(7); + return; + } + throwIfStopped(); if (mail.provider === HOTMAIL_PROVIDER) { await addLog(`步骤 7:正在通过 ${mail.label} 轮询验证码...`); diff --git a/sidepanel/sidepanel.css b/sidepanel/sidepanel.css index 478f54d..e6bbe94 100644 --- a/sidepanel/sidepanel.css +++ b/sidepanel/sidepanel.css @@ -1474,6 +1474,21 @@ header { margin-bottom: 14px; } +.modal-alert { + font-size: 12px; + line-height: 1.5; + margin-bottom: 14px; + padding: 9px 10px; + border-radius: 10px; + border: 1px solid transparent; +} + +.modal-alert.is-danger { + color: var(--red); + background: var(--red-soft); + border-color: rgba(220, 38, 38, 0.18); +} + .modal-option-row { margin-bottom: 14px; } diff --git a/sidepanel/sidepanel.html b/sidepanel/sidepanel.html index f9575de..944b7e7 100644 --- a/sidepanel/sidepanel.html +++ b/sidepanel/sidepanel.html @@ -152,6 +152,7 @@ 邮箱服务
检测到已有流程进度,选择继续当前还是重新开始。