diaryjump
script.js
function jumpMain() {
const hash = location.hash
const ptn = /^#(\d{4})-(\d{2})-(\d{2})$/
if (!hash || !ptn.test(hash)) {
return
}
const [, y, m, d] = hash.match(ptn)
const lines = scrapbox.Page?.lines || []
for (const [idx, line] of lines.entries()) {
const { id, text } = line
const _m = m.replace(/^0/, "")
const _d = d.replace(/^0/, "")
if (text === `${y}/${m}/${d}` || text === `${y}/${_m}/${_d}`) {
location.hash = `#${id}`
return
}
}
}
jumpMain()