From 62664ee862727b74b9d03378f3b0cc5d46f456a9 Mon Sep 17 00:00:00 2001 From: QLHazyCoder <2825305047@qq.com> Date: Sun, 12 Apr 2026 15:28:46 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E6=AD=A5=E9=AA=A4=20?= =?UTF-8?q?7=20=E4=BB=8E=E6=AD=A5=E9=AA=A4=206=20=E9=87=8D=E5=90=AF?= =?UTF-8?q?=E7=9A=84=E9=94=99=E8=AF=AF=E6=A0=87=E8=AE=B0=E6=9E=84=E5=BB=BA?= =?UTF-8?q?=E9=80=BB=E8=BE=91=EF=BC=8C=E4=BC=98=E5=8C=96=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- background.js | 53 +++++++++++++++++++++++++++++------------- content/signup-page.js | 5 ++++ 2 files changed, 42 insertions(+), 16 deletions(-) diff --git a/background.js b/background.js index 345a732..14ff076 100644 --- a/background.js +++ b/background.js @@ -1010,6 +1010,7 @@ function isVerificationMailPollingError(error) { } const STEP7_RESTART_FROM_STEP6_ERROR_CODE = 'STEP7_RESTART_FROM_STEP6'; +const STEP7_RESTART_FROM_STEP6_MARKER_PATTERN = /^STEP7_RESTART_FROM_STEP6::([^:]+)::(.*)$/; function createStep7RestartFromStep6Error(details = {}) { const { reason = 'unknown', url = '' } = details || {}; @@ -1023,15 +1024,35 @@ function createStep7RestartFromStep6Error(details = {}) { return error; } -function getStep7RestartFromStep6Error(result) { - if (!result?.restartFromStep6) { +function parseStep7RestartFromStep6Marker(message) { + const normalized = getErrorMessage(message); + const match = normalized.match(STEP7_RESTART_FROM_STEP6_MARKER_PATTERN); + if (!match) { return null; } - return createStep7RestartFromStep6Error(result); + + return { + reason: match[1] || 'unknown', + url: match[2] || '', + }; +} + +function getStep7RestartFromStep6Error(result) { + if (result?.restartFromStep6) { + return createStep7RestartFromStep6Error(result); + } + + const parsed = parseStep7RestartFromStep6Marker(result?.error); + if (!parsed) { + return null; + } + + return createStep7RestartFromStep6Error(parsed); } function isStep7RestartFromStep6Error(error) { - return error?.code === STEP7_RESTART_FROM_STEP6_ERROR_CODE; + return error?.code === STEP7_RESTART_FROM_STEP6_ERROR_CODE + || Boolean(parseStep7RestartFromStep6Marker(error)); } function isStep7RecoverableError(error) { @@ -2564,10 +2585,6 @@ async function requestVerificationCodeResend(step) { payload: {}, }); - if (result && result.error) { - throw new Error(result.error); - } - if (step === 7) { const restartError = getStep7RestartFromStep6Error(result); if (restartError) { @@ -2575,6 +2592,10 @@ async function requestVerificationCodeResend(step) { } } + if (result && result.error) { + throw new Error(result.error); + } + return Date.now(); } @@ -2657,10 +2678,6 @@ async function submitVerificationCode(step, code) { payload: { code }, }); - if (result && result.error) { - throw new Error(result.error); - } - if (step === 7) { const restartError = getStep7RestartFromStep6Error(result); if (restartError) { @@ -2668,6 +2685,10 @@ async function submitVerificationCode(step, code) { } } + if (result && result.error) { + throw new Error(result.error); + } + return result || {}; } @@ -2882,15 +2903,15 @@ async function runStep7Attempt(state) { payload: {}, }); - if (prepareResult && prepareResult.error) { - throw new Error(prepareResult.error); - } - const restartError = getStep7RestartFromStep6Error(prepareResult); if (restartError) { throw restartError; } + if (prepareResult && prepareResult.error) { + throw new Error(prepareResult.error); + } + await addLog(`步骤 7:正在打开${mail.label}...`); const alive = await isTabAlive(mail.source); diff --git a/content/signup-page.js b/content/signup-page.js index 4ceb2d4..8c5a102 100644 --- a/content/signup-page.js +++ b/content/signup-page.js @@ -658,12 +658,17 @@ function isSignupPasswordErrorPage() { return matchesAuthTimeoutErrorPage(/\/create-account\/password(?:[/?#]|$)/i); } +function buildStep7RestartFromStep6Marker(reason, url = location.href) { + return `STEP7_RESTART_FROM_STEP6::${reason || 'unknown'}::${url || ''}`; +} + function getStep7RestartFromStep6Signal() { if (!isLoginPage() || !matchesAuthTimeoutErrorPage(/\/log-in(?:[/?#]|$)/i)) { return null; } return { + error: buildStep7RestartFromStep6Marker('login_timeout_error_page', location.href), restartFromStep6: true, reason: 'login_timeout_error_page', url: location.href,