-
Notifications
You must be signed in to change notification settings - Fork 0
/
service_worker.js
33 lines (30 loc) · 949 Bytes
/
service_worker.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
29
30
31
32
33
chrome.runtime.onMessage.addListener(async (message, sender) => {
if (message.type === "getInitialSetup") {
await chrome.storage.sync.get(
["langPractice", "duotokEnabled"],
(result) => {
const settings = {
langPractice: result.langPractice,
duotokEnabled: result.duotokEnabled,
};
chrome.tabs.sendMessage(sender.tab.id, settings);
}
);
return true;
}
if (message.type === "AUDIO_AVAILABILITY") {
await chrome.storage.sync.set({ audioAvailability: message.availability });
return true;
}
if (message.type === "SUBTITLE_AVAILABILITY") {
await chrome.storage.sync.set({
subtitleAvailability: message.availability,
});
return true;
}
if (message.type === "RELOAD") {
chrome.tabs.reload();
}
});
// Get feedback on uninstall.
chrome.runtime.setUninstallURL("https://forms.gle/m3YRuRmBYQ9dE5gC6");