-
Notifications
You must be signed in to change notification settings - Fork 1
/
popup.js
35 lines (33 loc) · 1.33 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
35
function toggleTheme()
{
if (document.getElementById('check').checked){
chrome.storage.sync.set({theme: 'dark'}, function() {
console.log('Theme set to dark');
});
document.body.style.setProperty('--main-bg-color',"#555")
document.body.style.setProperty('--button-color',"whitesmoke")
document.body.style.setProperty('--desc-color',"whitesmoke")
} else {
chrome.storage.sync.set({theme: 'light'}, function() {
console.log('Theme set to light');
});
document.body.style.setProperty('--main-bg-color',"whitesmoke")
document.body.style.setProperty('--button-color',"black")
document.body.style.setProperty('--desc-color',"black")
}
}
document.addEventListener('DOMContentLoaded', function() {
var link = document.getElementById('check');
link.addEventListener('click', toggleTheme);
});
window.onload = () => {
chrome.storage.sync.get(['theme'], r => {
console.log(r)
if(r['theme'] === 'dark'){
document.body.style.setProperty('--main-bg-color',"#555")
document.body.style.setProperty('--button-color',"whitesmoke")
document.body.style.setProperty('--desc-color',"whitesmoke")
document.getElementById('check').checked = true
}
});
}