generated at
scrapbox-theme-customizer
ScrapboxのThemeをUserScriptから変更するやつ

使い方
js
import {setTheme} from '/api/code/takker/scrapbox-theme-customizer/script.js'; setTheme('papar-dark-dark');

本体
script.js
import {themes} from '../ScrapboxのTheme/script.js'; let executed = false; export function setTheme(theme) { if (executed) return; executed = true; if (!themes.includes(theme)) throw Error(`"${theme}" is an invalid theme name.`);
data-project-theme が存在しない場合もあるので、 setAttribute() を使って設定している
script.js
// 初期化 document.documentElement.setAttribute("data-project-theme", theme); // ページ更新用 const observer = new MutationObserver(() => { document.documentElement.setAttribute("data-project-theme", theme); }); observer.observe(document.head.getElementsByTagName('title')?.[0], {childList: true}); }

#2021-03-21 03:55:33
#2021-02-27 01:38:11
#2021-01-15 13:11:03