-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpopup.js
27 lines (24 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
document.addEventListener("DOMContentLoaded", function () {
const actionMenuCheckbox = document.getElementById("actionMenuToggle");
const shortsCheckbox = document.getElementById("shortsToggle");
const blacklistTextarea = document.getElementById("blacklist");
const saveButton = document.getElementById("saveButton");
chrome.storage.sync.get("options", function ({ options }) {
const actionMenuToggle = options?.actionMenuToggle ?? false;
const shortsToggle = options?.shortsToggle ?? false;
const blacklist = options?.blacklist ?? [];
actionMenuCheckbox.checked = actionMenuToggle;
shortsCheckbox.checked = shortsToggle;
blacklistTextarea.value = blacklist.join("\n");
});
saveButton.addEventListener("click", function () {
const options = {
actionMenuToggle: actionMenuCheckbox.checked,
shortsToggle: shortsCheckbox.checked,
blacklist: blacklistTextarea.value.split("\n"),
};
chrome.storage.sync.set({ options }, function () {
alert("Saved!");
});
});
});