scrapboxのrandomボタンが好きなのではてなブログでも出したいと思って作った。うまくいっていれば→のサイドバーに出ています。
こういう感じのHTMLを書いて、HTMLモジュールってやつでおいている *1
<button onclick='javascript: fetch("/rss").then(r => r.text()).then(data => { const parser = new DOMParser(); return parser.parseFromString(data, "text/xml") }).then(dom => {const items = dom.querySelectorAll("channel>item"); const item = items[ Math.floor(Math.random() * items.length) ]; location.href = item.querySelector("link").innerHTML; })' style="font-size: 120%; border: none; background: none; cursor: pointer;">🔄</button>
後から考えると関連記事モジュールでも十分な気がする