自動スクロール機能
code:style.css
a#AutoScroll.tool-btn:hover { text-decoration: none }
a#AutoScroll.tool-btn::before { position: absolute; left: calc(46px/3 - 1px); content: '\f70e'; font: 900 21px/46px 'Font Awesome 5 Free' }
a#AutoScroll.tool-btn img { opacity: 0 }
2. このスクリプトをユーザーページにコピペ
code:script.js
addAutoScrollItemsToPageMenu()
function addAutoScrollItemsToPageMenu() {
var interval_num = 0;
const __autoScrolls = [
{ title: 'speed1', speed: 500 },
{ title: 'speed2', speed: 400 },
{ title: 'speed3', speed: 300 },
{ title: 'speed4', speed: 100 },
{ title: 'speed5', speed: 50 },
{ title: 'stop', speed: 0 }
]
const __autoScrollMenuTitle = 'AutoScroll'
scrapbox.PageMenu.addMenu({ title: __autoScrollMenuTitle, image:'/assets/img/logo_cut.svg', onClick: () => { } })
__autoScrolls.forEach((i) => {
scrapbox.PageMenu(__autoScrollMenuTitle).addItem({
title: i.title,
onClick: () => { __loadAutoScroll(i.speed) }})
})
var __loadAutoScroll = function (speed) {
if (interval_num != 0) {
clearInterval(interval_num);
if (speed == 0) {
clearInterval(interval_num);
return
}
}
var scrollInterval = setInterval(__ScrollFW, speed);
console.log(typeof scrollInterval)
console.log(scrollInterval)
interval_num = scrollInterval;
}
var __ScrollFW = function (){
if (__isAtBottom() == false){
//window.scrollBy(0,1);
window.scrollBy({
top: 5,
left: 0,
behavior: 'smooth'
})
} else {
if (interval_num != 0) {
clearInterval(interval_num);
}
}
}
var __isAtBottom = function (){
var a,b,c,d;
a=document.documentElement.scrollHeight;
b=document.documentElement.scrollTop;
c=document.documentElement.clientHeight;
d=document.getElementsByClassName('related-page-list')0.clientHeight; //links-1-hopはだめ return ((a-b-d)<=c);
}
}