commit ad4420f01a7f389cb1276becd50970a3c4e8b803
parent 38f306549fd802fbb7cbe1ea6750584f73d52303
Author: JayVii <jayvii[AT]posteo[DOT]de>
Date: Sun, 2 Jun 2024 18:45:52 +0200
if cookies are denied, use temporary sessionstorage
Diffstat:
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/template.html b/template.html
@@ -44,6 +44,8 @@
}
if (set_cookie) {
document.cookie="dark-mode=" + set_mode + ";SameSite=Strict";
+ } else {
+ sessionStorage.setItem("dark-mode", set_mode);
}
}
// On Load: set dark mode if necessary
@@ -53,7 +55,9 @@
(window.matchMedia('(prefers-color-scheme: dark)').matches &&
document.cookie == "") ||
// Case 2: Dark Mode is set via cookie
- document.cookie == "dark-mode=1"
+ document.cookie == "dark-mode=1" ||
+ // Case 3: Dark Mode is set via session Storage
+ sessionStorage.getItem("dark-mode") == 1
) {
toggleTheme(set_mode = 1);
} else {