From bef70f6db3cb0af70b99ba7fcc56c38edc9fa6b1 Mon Sep 17 00:00:00 2001 From: tophf Date: Fri, 18 Feb 2022 04:40:23 +0300 Subject: [PATCH] fix light mode in dark system, properly --- js/dark-themer.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/js/dark-themer.js b/js/dark-themer.js index 400c53a3..04bf1a28 100644 --- a/js/dark-themer.js +++ b/js/dark-themer.js @@ -12,6 +12,9 @@ */ API.colorScheme.shouldIncludeStyle('darkUI').then(val => { + const ON = 'screen'; + const OFF = 'not all'; + const map = {[ON]: true, [OFF]: false}; let isDark = val; toggleDarkStyles(); msg.onExtension(e => { @@ -24,8 +27,8 @@ API.colorScheme.shouldIncludeStyle('darkUI').then(val => { $.root.dataset.uiTheme = isDark ? 'dark' : 'light'; for (const sheet of document.styleSheets) { for (const {media: m} of sheet.cssRules) { - if (m && m[1] === 'dark' && /screen/.test(m[0]) !== isDark) { - m.mediaText = isDark ? 'screen,dark' : 'not all,dark'; + if (m && m[1] === 'dark' && map[m[0]] !== isDark) { + m.mediaText = `${isDark ? ON : OFF},dark`; } } }