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

Function openIcloudLoginPage

background.js:2859–2885  ·  view source on GitHub ↗
(preferredUrl)

Source from the content-addressed store, hash-verified

2857let lastIcloudLoginPromptAt = 0;
2858
2859async function openIcloudLoginPage(preferredUrl) {
2860 const tabs = await chrome.tabs.query({
2861 url: [
2862 'https://www.icloud.com/*',
2863 'https://www.icloud.com.cn/*',
2864 ],
2865 });
2866 const preferredHost = new URL(preferredUrl).host;
2867 const existing = tabs.find((tab) => {
2868 try {
2869 return new URL(tab.url).host === preferredHost;
2870 } catch {
2871 return false;
2872 }
2873 });
2874
2875 if (existing?.id) {
2876 await chrome.tabs.update(existing.id, { active: true });
2877 if (existing.url !== preferredUrl) {
2878 await chrome.tabs.update(existing.id, { url: preferredUrl });
2879 }
2880 return existing.id;
2881 }
2882
2883 const created = await chrome.tabs.create({ url: preferredUrl, active: true });
2884 return created.id;
2885}
2886
2887async function promptIcloudLogin(error, actionLabel = 'iCloud 操作') {
2888 const now = Date.now();

Callers 1

promptIcloudLoginFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected