From 4aebe9542be669e7d2cc07ac7277e3954ded9dc4 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Thu, 11 Nov 2021 03:18:40 +0100 Subject: [PATCH] default dark mode to the user's color scheme --- main/scripts/main.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/main/scripts/main.js b/main/scripts/main.js index 4c78f61..d52c200 100644 --- a/main/scripts/main.js +++ b/main/scripts/main.js @@ -1,4 +1,5 @@ -const dark = getCookie("dark") === "true"; +const darkCookie = getCookie("dark"); +const dark = darkCookie == undefined ? window.matchMedia("(prefers-color-scheme: dark)").matches : darkCookie == "true"; if (dark) addStyle("/style/dark.css");