-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackground.js
More file actions
35 lines (30 loc) · 877 Bytes
/
Copy pathbackground.js
File metadata and controls
35 lines (30 loc) · 877 Bytes
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
29
30
31
32
33
34
35
importScripts(
"background/rendered-score-client.js",
"background/api-client.js"
);
chrome.runtime.onMessage.addListener((request, _sender, sendResponse) => {
if (request?.action !== "checkSakuraScore") {
return false;
}
self.ApiClient.checkSakuraScore({
asin: request.asin,
forceRefresh: request.forceRefresh === true,
productUrl: request.productUrl,
})
.then((result) => sendResponse(result))
.catch((error) => {
sendResponse({
ok: false,
code: "network_error",
message: error instanceof Error ? error.message : "Unexpected background error.",
sourceUrl: self.ApiClient.buildDetailUrl(request.asin),
});
});
return true;
});
self.addEventListener("install", () => {
self.skipWaiting();
});
self.addEventListener("activate", (event) => {
event.waitUntil(self.clients.claim());
});