From b846677580a0b715de4efb508820dc6f8bfed8cb Mon Sep 17 00:00:00 2001 From: Cory Zibell Date: Tue, 8 Sep 2020 01:04:33 -0400 Subject: [PATCH] Use Notion's localstorage native theme setting for night shift instead of overriding classes. --- mods/night-shift/mod.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/mods/night-shift/mod.js b/mods/night-shift/mod.js index 51d5702..8f9e292 100644 --- a/mods/night-shift/mod.js +++ b/mods/night-shift/mod.js @@ -29,13 +29,11 @@ module.exports = { attributes: true, }); function process(list, observer) { - const mode = `notion-app-inner notion-${ - window.matchMedia('(prefers-color-scheme: dark)').matches - ? 'dark' - : 'light' - }-theme`; - if (list[0].target.className !== mode) - list[0].target.className = mode; + const mode = window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light' + if (!window.localStorage.getItem('theme').includes(mode)) { + window.localStorage.setItem('theme', `{"mode":"${mode}"}`) + location.reload() + } } } });