plugins
plugins copied to clipboard
🧩 logseq.App.onThemeModeChanged
Get theme color from DOM
let background; //background-color
let color; //color
const rootThemeColor = () => {
const root = parent.document.querySelector(":root");
if (root) {
const rootStyles = getComputedStyle(root);
background = rootStyles.getPropertyValue("--ls-block-properties-background-color") || "#ffffff";
color = rootStyles.getPropertyValue("--ls-primary-text-color") || "#000000";
}
};
rootThemeColor();
logseq.App.onThemeModeChanged(() => { rootThemeColor(); });
//Credit: YU000jp
https://github.com/YU000jp/logseq-plugin-weekdays-and-weekends/blob/34e65b3a0f53062938e513110c15641a39a8112d/src/index.ts#L17