Use Notion's localstorage native theme setting for night shift instead of overriding classes.

This commit is contained in:
Cory Zibell 2020-09-08 01:04:33 -04:00
parent f304f78177
commit b846677580

View File

@ -29,13 +29,11 @@ module.exports = {
attributes: true, attributes: true,
}); });
function process(list, observer) { function process(list, observer) {
const mode = `notion-app-inner notion-${ const mode = window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'
window.matchMedia('(prefers-color-scheme: dark)').matches if (!window.localStorage.getItem('theme').includes(mode)) {
? 'dark' window.localStorage.setItem('theme', `{"mode":"${mode}"}`)
: 'light' location.reload()
}-theme`; }
if (list[0].target.className !== mode)
list[0].target.className = mode;
} }
} }
}); });