From f0b2ac7c5d909035a8dcd63ea67f472080a61ea2 Mon Sep 17 00:00:00 2001 From: Mikhael Skvortsov Date: Tue, 16 Apr 2024 18:38:48 +0300 Subject: [PATCH] Detect browser theme --- meshmon.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/meshmon.js b/meshmon.js index ef8edce..084a155 100644 --- a/meshmon.js +++ b/meshmon.js @@ -472,6 +472,9 @@ window.onload = function() { if (currentTheme === 'dark') { toggleSwitch.checked = true; } + } else if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) { + document.documentElement.setAttribute('data-theme', 'dark'); + toggleSwitch.checked = true; } toggleSwitch.addEventListener('change', switchTheme, false);