fix(auth): OAuth 登录使用全新标签页
(cherry picked from commit b3790c1c4de466e619ea6acfd571531a4ba2ef3c)
This commit is contained in:
@@ -75,7 +75,7 @@
|
|||||||
await addLog(`步骤 7:上一轮失败后,正在进行第 ${attempt} 次尝试(最多 ${STEP6_MAX_ATTEMPTS} 次)...`, 'warn');
|
await addLog(`步骤 7:上一轮失败后,正在进行第 ${attempt} 次尝试(最多 ${STEP6_MAX_ATTEMPTS} 次)...`, 'warn');
|
||||||
}
|
}
|
||||||
|
|
||||||
await reuseOrCreateTab('signup-page', oauthUrl);
|
await reuseOrCreateTab('signup-page', oauthUrl, { forceNew: true });
|
||||||
|
|
||||||
const result = await sendToContentScriptResilient(
|
const result = await sendToContentScriptResilient(
|
||||||
'signup-page',
|
'signup-page',
|
||||||
|
|||||||
@@ -527,6 +527,31 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function reuseOrCreateTab(source, url, options = {}) {
|
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);
|
const alive = await isTabAlive(source);
|
||||||
if (alive) {
|
if (alive) {
|
||||||
const tabId = await getTabId(source);
|
const tabId = await getTabId(source);
|
||||||
|
|||||||
Reference in New Issue
Block a user