Last active
August 23, 2022 03:08
-
-
Save nozma/b41f61d2d5aa2aa50d82123bd6cca94c to your computer and use it in GitHub Desktop.
scrapboxのuserscript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// テーブルの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