-
Notifications
You must be signed in to change notification settings - Fork 3
/
popup.js
34 lines (31 loc) · 1.16 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
33
34
document.getElementById("save").addEventListener("click", () => {
const replaceWord = document.getElementById("keywords").value.trim();
browser.storage.sync.set({ replaceWord }, () => {
alert("Custom replace word saved!");
});
});
document.getElementById("toggle").addEventListener("change", (event) => {
const isEnabled = event.target.checked;
browser.storage.sync.set({ isEnabled }, () => {
console.log("Extension state saved:", isEnabled);
});
});
document
.getElementById("replace-toggle")
.addEventListener("change", (event) => {
const replaceComments = event.target.checked;
browser.storage.sync.set({ replaceComments }, () => {
console.log("Replace comments state saved:", replaceComments);
});
});
// Load the current state of the toggles
browser.storage.sync.get(
["isEnabled", "replaceComments", "replaceWord"],
(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
document.getElementById("keywords").value =
data.replaceWord || "[Blocked Comment]";
},
);