MCPcopy Create free account
hub / github.com/dailydotdev/apps / sendBootData

Function sendBootData

packages/extension/src/background/index.ts:103–135  ·  view source on GitHub ↗
(_: unknown, tab?: Tabs.Tab)

Source from the content-addressed store, hash-verified

101};
102
103const 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
137const sendRequestResponse = async (
138 requestKey: string,

Callers 1

handleMessagesFunction · 0.85

Calls 4

getLocalBootDataFunction · 0.90
getOrGenerateDeviceIdFunction · 0.90
getBootDataFunction · 0.90
isExcludedFunction · 0.85

Tested by

no test coverage detected