未読のページにランダムジャンプするUserScript
script.jsscrapbox.PageMenu.addMenu({
title: 'Jump to an unread page',
image: 'https://img.icons8.com/ios/180/shuffle.png',
onClick: () => {
const lines = document.getElementsByClassName('lines')?.[0];
const observer = new MutationObserver(() => {
const unreadTelomeres = lines.getElementsByClassName('telomere-border unread');
if (unreadTelomeres.length > 0) {
console.log(`/${scrapbox.Project.name}/${scrapbox.Page.title} is an unread page.`);
observer.disconnect();
return;
}
document.getElementsByClassName('random-jump-button')?.[0].click();
});
observer.observe(lines, {childList: true});
document.getElementsByClassName('random-jump-button')?.[0].click();
},
});