(_: unknown, tab?: Tabs.Tab)
| 101 | }; |
| 102 | |
| 103 | const sendBootData = async (_: unknown, tab?: Tabs.Tab) => { |
| 104 | if (!tab?.url || !tab.id) { |
| 105 | return; |
| 106 | } |
| 107 | |
| 108 | const { origin, pathname, search } = new URL(tab.url); |
| 109 | if (isExcluded(origin)) { |
| 110 | return; |
| 111 | } |
| 112 | |
| 113 | const cacheData = getLocalBootData(); |
| 114 | if (cacheData?.settings?.optOutCompanion) { |
| 115 | return; |
| 116 | } |
| 117 | |
| 118 | const href = origin + pathname + search; |
| 119 | |
| 120 | const [deviceId, boot] = await Promise.all([ |
| 121 | getOrGenerateDeviceId(), |
| 122 | getBootData({ app: 'companion', url: href }), |
| 123 | ]); |
| 124 | |
| 125 | let settingsOutput = boot.settings; |
| 126 | if (!cacheData?.user || !('providers' in cacheData?.user)) { |
| 127 | settingsOutput = { ...settingsOutput, ...cacheData?.settings }; |
| 128 | } |
| 129 | await browser.tabs.sendMessage(tab.id, { |
| 130 | ...boot, |
| 131 | deviceId, |
| 132 | url: href, |
| 133 | settings: settingsOutput, |
| 134 | }); |
| 135 | }; |
| 136 | |
| 137 | const sendRequestResponse = async ( |
| 138 | requestKey: string, |
no test coverage detected