()
| 2788 | } |
| 2789 | |
| 2790 | async function getOpenIcloudHostPreference() { |
| 2791 | try { |
| 2792 | const tabs = await chrome.tabs.query({ |
| 2793 | url: [ |
| 2794 | 'https://www.icloud.com/*', |
| 2795 | 'https://www.icloud.com.cn/*', |
| 2796 | ], |
| 2797 | }); |
| 2798 | |
| 2799 | const activeTab = tabs.find((tab) => tab.active); |
| 2800 | const candidates = activeTab ? [activeTab, ...tabs.filter((tab) => tab.id !== activeTab.id)] : tabs; |
| 2801 | for (const tab of candidates) { |
| 2802 | try { |
| 2803 | const host = normalizeIcloudHost(new URL(tab.url).host); |
| 2804 | if (host) return host; |
| 2805 | } catch {} |
| 2806 | } |
| 2807 | } catch {} |
| 2808 | |
| 2809 | return ''; |
| 2810 | } |
| 2811 | |
| 2812 | async function getPreferredIcloudLoginUrl(error = null, state = null) { |
| 2813 | const currentState = state || await getState(); |
no test coverage detected