MCPcopy Index your code
hub / github.com/QLHazyCoder/FlowPilot / closeLocalhostCallbackTabs

Function closeLocalhostCallbackTabs

background/tab-runtime.js:101–124  ·  view source on GitHub ↗
(callbackUrl, options = {})

Source from the content-addressed store, hash-verified

99 }
100
101 async function closeLocalhostCallbackTabs(callbackUrl, options = {}) {
102 if (!isLocalhostOAuthCallbackUrl(callbackUrl)) return 0;
103
104 const { excludeTabIds = [] } = options;
105 const excluded = new Set(excludeTabIds.filter((id) => Number.isInteger(id)));
106 const tabs = await chrome.tabs.query({});
107 const matchedIds = tabs
108 .filter((tab) => Number.isInteger(tab.id) && !excluded.has(tab.id))
109 .filter((tab) => isLocalhostOAuthCallbackTabMatch(callbackUrl, tab.url))
110 .map((tab) => tab.id);
111
112 if (!matchedIds.length) return 0;
113
114 await chrome.tabs.remove(matchedIds).catch(() => { });
115
116 const registry = await getTabRegistry();
117 if (registry['signup-page']?.tabId && matchedIds.includes(registry['signup-page'].tabId)) {
118 registry['signup-page'] = null;
119 await setState({ tabRegistry: registry });
120 }
121
122 await addLog(`已关闭 ${matchedIds.length} 个匹配当前 OAuth callback 的 localhost 残留标签页。`, 'info');
123 return matchedIds.length;
124 }
125
126 function buildLocalhostCleanupPrefix(rawUrl) {
127 if (!isLocalhostOAuthCallbackUrl(rawUrl)) return '';

Callers 1

handleStepDataFunction · 0.70

Calls 5

setStateFunction · 0.85
getTabRegistryFunction · 0.70
addLogFunction · 0.70

Tested by

no test coverage detected