Skip to content

Instantly share code, notes, and snippets.

@nozma
Last active August 23, 2022 03:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nozma/b41f61d2d5aa2aa50d82123bd6cca94c to your computer and use it in GitHub Desktop.
Save nozma/b41f61d2d5aa2aa50d82123bd6cca94c to your computer and use it in GitHub Desktop.
scrapboxのuserscript
// テーブルの1行目を太字、中央揃えするための処理 ----
// テーブルのタイトルにクラスを付与
function addTableStartClass() {
$('.line').has('.table-block-start').addClass("table-start");
};
addTableStartClass();
// 行選択でクラス名が変更される対策でDOMを監視
// (by https://scrapbox.io/customize/インデント毎に背景色を変える#5fca6962bacd1c0000143f41)
(function () {
const target = document.getElementById('app-container')
const observer = new MutationObserver(records => addTableStartClass() )
observer.observe(target, {
childList: true,
subtree: true
})
})()
// タイムスタンプのフォーマット追加
scrapbox.TimeStamp.addFormat('hh:mm')
// 画像読み込みが遅れた場合にアンカーがずれる対策
// 読み込みが遅れた画像の読み込みが完了する都度アンカーを叩く
(() => {
var img_elements = document.querySelectorAll("img");
for(var i = 0; i < img_elements.length; i++) {
img_elements[i].addEventListener("load", () => {
var target = location.hash;
if (target != "") window.location.href = target;
});
}
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment