-
Notifications
You must be signed in to change notification settings - Fork 1
/
popup.js
28 lines (24 loc) · 1.09 KB
/
popup.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
/**
* Check if initial setup is required in background service worker
*/
chrome.runtime.sendMessage({ type: "popup_message", key: "isBackgroundTaskRequired", message: null}, (response) => {
console.log(response.message);
if (response.message) showExtensionNotReady();
else showExtensionReady();
});
function showExtensionReady() {
const elesToShow = document.querySelectorAll(".extension_ready");
const elesToHide = document.querySelectorAll(".extension_not_ready");
elesToShow.forEach(ele => ele.style.display = "flex");
elesToHide.forEach(ele => ele.style.display = "none");
}
function showExtensionNotReady() {
const elesToShow = document.querySelectorAll(".extension_not_ready");
const elesToHide = document.querySelectorAll(".extension_ready");
elesToShow.forEach(ele => ele.style.display = "flex");
elesToHide.forEach(ele => ele.style.display = "none");
}
const updateBtns = document.querySelectorAll("#extensionResetBtn");
updateBtns.forEach(btn => btn.addEventListener("click", () => {
chrome.runtime.sendMessage({ type: "popup_message", key: "resetExtension", message: null});
}));