-
Notifications
You must be signed in to change notification settings - Fork 3
/
popup.js
32 lines (29 loc) · 1.1 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
document.getElementById("save").addEventListener("click", () => {
const keywords = document
.getElementById("keywords")
.value.split(",")
.map((kw) => kw.trim().toLowerCase());
chrome.storage.sync.set({ keywords }, () => {
alert("Keywords saved!");
});
});
document.getElementById("toggle").addEventListener("change", (event) => {
const isEnabled = event.target.checked;
chrome.storage.sync.set({ isEnabled }, () => {
console.log("Extension state saved:", isEnabled);
});
});
document
.getElementById("replace-toggle")
.addEventListener("change", (event) => {
const replaceComments = event.target.checked;
chrome.storage.sync.set({ replaceComments }, () => {
console.log("Replace comments state saved:", replaceComments);
});
});
// Load the current state of the toggles
chrome.storage.sync.get(["isEnabled", "replaceComments"], (data) => {
document.getElementById("toggle").checked = data.isEnabled !== false; // Default to enabled if not set
document.getElementById("replace-toggle").checked =
data.replaceComments === true; // Default to remove if not set
});