-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpreload.js
30 lines (27 loc) · 822 Bytes
/
preload.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
let darkModeEnabled = window.matchMedia('(prefers-color-scheme: dark)').matches;
var storedTheme = localStorage.getItem("globalTheme");
if(!storedTheme){
var element = document.body;
var containDarkMode = element.classList.contains("dark-mode");
if(darkModeEnabled){
if(!containDarkMode){
element.classList.add("dark-mode");
}
}else{
if(containDarkMode){
element.classList.remove("dark-mode");
}
}
}else{
var element = document.body;
var containDarkMode = element.classList.contains("dark-mode");
if(storedTheme == 'dark-mode'){
if(!containDarkMode){
element.classList.add("dark-mode");
}
}else{
if(containDarkMode){
element.classList.remove("dark-mode");
}
}
}