-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
background.js
28 lines (26 loc) · 854 Bytes
/
background.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// background.js
chrome.runtime.onInstalled.addListener(() => {
console.log("PythagorasHIM™ 4 Obra Prima extension installed");
});
chrome.runtime.onMessage.addListener(async (request, sender, sendResponse) => {
if (request.action === "getSelectedClient") {
try {
const data = await chrome.storage.local.get("selectedClient");
sendResponse({ selectedClient: data.selectedClient });
} catch (error) {
console.error(error);
sendResponse({ selectedClient: null });
}
return true;
}
if (request.action === "getSelectedSupplier") {
try {
const data = await chrome.storage.local.get("selectedSupplier");
sendResponse({ selectedSupplier: data.selectedSupplier });
} catch (error) {
console.error(error);
sendResponse({ selectedSupplier: null });
}
return true;
}
});