-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontent.js
28 lines (25 loc) · 869 Bytes
/
content.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
// content.js
// Toggle dark mode
function toggleDarkMode(darkModeEnabled, backgroundColor, textColor, linkColor) {
if (darkModeEnabled) {
document.body.classList.add("dark-mode");
document.documentElement.style.setProperty("--dark-mode-background-color", backgroundColor);
document.documentElement.style.setProperty("--dark-mode-text-color", textColor);
document.documentElement.style.setProperty("--dark-mode-link-color", linkColor);
} else {
document.body.classList.remove("dark-mode");
}
}
// Initialize dark mode
function init() {
chrome.storage.sync.get({
darkModeEnabled: true,
backgroundColor: "#222222",
textColor: "#eeeeee",
linkColor: "#88ccff",
}, function (items) {
toggleDarkMode(items.darkModeEnabled, items.backgroundColor, items.textColor, items.linkColor);
});
}
// Execute initialization
init();