notion-enhancer/extension/repo/theming@0f0bf8b6-eae6-4273-b307-8fc43f2ee082/client.mjs

20 lines
588 B
JavaScript

/*
* notion-enhancer core: theming
* (c) 2021 dragonwocky <thedragonring.bod@gmail.com> (https://dragonwocky.me/)
* (https://notion-enhancer.github.io/) under the MIT license
*/
'use strict';
export default function (api, db) {
const { web } = api;
const $root = document.querySelector(':root');
$root.classList[document.body.classList.contains('dark') ? 'add' : 'remove']('dark');
web.addDocumentObserver((mutation) => {
if (mutation.target === document.body) {
$root.classList[document.body.classList.contains('dark') ? 'add' : 'remove']('dark');
}
});
}