-
Notifications
You must be signed in to change notification settings - Fork 0
/
popup.js
32 lines (26 loc) · 1.02 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
29
30
31
32
const toggle = document.getElementById("highlightToggle");
const donwloadBtn = document.getElementById("downloadBtn");
/*chrome.storage.sync.get(["highlightEnabled"], (result) => {
toggle.checked = result.highlightEnabled || false;
});*/
toggle.checked = (localStorage.getItem("isActive") === "true") || false;
toggle.addEventListener("change", () => {
let value = toggle.checked;
/*chrome.storage.sync.set({highlightEnabled: value}, () => {
console.log("Error Storage: " + chrome.runtime.lastError);
});*/
console.log(localStorage.getItem("isActive"));
localStorage.setItem("isActive", value);
chrome.tabs.query({}, (tabs) => {
for (const tab of tabs) {
chrome.tabs.sendMessage(tab.id, { action: "toggle" });
}
});
});
donwloadBtn.addEventListener("click", () => {
console.log("clicked");
chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
console.log(tabs)
chrome.tabs.sendMessage(tabs[0].id, { action: "download" });
});
});