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

import.js
import {setTheme} from './script.js'; setTheme('paper-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.`); // 初期化 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}); }

data-project-theme が存在しない場合もあるので、 setAttribute() を使って設定している