-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoptions.js
37 lines (33 loc) · 1.21 KB
/
options.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
35
36
37
// options.js
// Save options
function saveOptions() {
const darkModeEnabled = document.getElementById("darkModeEnabled").checked;
const backgroundColor = document.getElementById("backgroundColor").value;
const textColor = document.getElementById("textColor").value;
const linkColor = document.getElementById("linkColor").value;
chrome.storage.sync.set({
darkModeEnabled: darkModeEnabled,
backgroundColor: backgroundColor,
textColor: textColor,
linkColor: linkColor,
}, function () {
console.log("Options saved");
});
}
// Restore options
function restoreOptions() {
chrome.storage.sync.get({
darkModeEnabled: true,
backgroundColor: "#222222",
textColor: "#eeeeee",
linkColor: "#88ccff",
}, function (items) {
document.getElementById("darkModeEnabled").checked = items.darkModeEnabled;
document.getElementById("backgroundColor").value = items.backgroundColor;
document.getElementById("textColor").value = items.textColor;
document.getElementById("linkColor").value = items.linkColor;
});
}
// Register event listeners
document.addEventListener("DOMContentLoaded", restoreOptions);
document.getElementById("saveButton").addEventListener("click", saveOptions);