From 8efdc811db4adc213ff3afab8123fd202602203c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=B4=E5=9C=A3=E4=BD=91?= Date: Sun, 26 Apr 2026 22:23:49 +0800 Subject: [PATCH] =?UTF-8?q?fix(auth):=20OAuth=20=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E5=85=A8=E6=96=B0=E6=A0=87=E7=AD=BE=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (cherry picked from commit b3790c1c4de466e619ea6acfd571531a4ba2ef3c) --- background/steps/oauth-login.js | 2 +- background/tab-runtime.js | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/background/steps/oauth-login.js b/background/steps/oauth-login.js index f24178e..6a323ce 100644 --- a/background/steps/oauth-login.js +++ b/background/steps/oauth-login.js @@ -75,7 +75,7 @@ await addLog(`步骤 7:上一轮失败后,正在进行第 ${attempt} 次尝试(最多 ${STEP6_MAX_ATTEMPTS} 次)...`, 'warn'); } - await reuseOrCreateTab('signup-page', oauthUrl); + await reuseOrCreateTab('signup-page', oauthUrl, { forceNew: true }); const result = await sendToContentScriptResilient( 'signup-page', diff --git a/background/tab-runtime.js b/background/tab-runtime.js index 17b3275..6a4c004 100644 --- a/background/tab-runtime.js +++ b/background/tab-runtime.js @@ -527,6 +527,31 @@ } async function reuseOrCreateTab(source, url, options = {}) { + if (options.forceNew) { + await closeConflictingTabsForSource(source, url); + const tab = await chrome.tabs.create({ url, active: true }); + + if (options.inject) { + await waitForTabUpdateComplete(tab.id); + if (options.injectSource) { + await chrome.scripting.executeScript({ + target: { tabId: tab.id }, + func: (injectedSource) => { + window.__MULTIPAGE_SOURCE = injectedSource; + }, + args: [options.injectSource], + }); + } + await chrome.scripting.executeScript({ + target: { tabId: tab.id }, + files: options.inject, + }); + } + + await rememberSourceLastUrl(source, url); + return tab.id; + } + const alive = await isTabAlive(source); if (alive) { const tabId = await getTabId(source);