因为发现又朋友在用,所以根据需求做了一些修改。
【如何安装:】 https://bookmarklet.appinn.me
滚动版
-
stepTime
表示速度,数值越大,速度越慢……(诶,其实代表滚动一像素需要多少毫秒; - 点书签开始滚动;
- 点网页空白处切换滚动状态(开始/停止);
- 双击网页空白返回顶部
javascript: (function () {
const d = document.documentElement;
const stepTime = 40;
const scroll = {};
const stopScroll = ()=>{
scroll.state = false;
scroll.time = null;
scroll.pos = null;
};
stopScroll();
const scrollThisPage = (timestamp)=>{
if(scroll.time){
scroll.pos = scroll.pos!==null ? scroll.pos + (timestamp - scroll.time)/stepTime : d.scrollTop;
d.scrollTop = scroll.pos;
}
scroll.time = timestamp;
if(d.scrollTop < d.scrollHeight-window.innerHeight-10 && scroll.state){
window.requestAnimationFrame(scrollThisPage);
}else{
stopScroll();
}
};
scroll.state = true;
window.requestAnimationFrame(scrollThisPage);
d.onclick = ()=>{
if(scroll.state){
stopScroll();
}else{
scroll.state = true;
window.requestAnimationFrame(scrollThisPage);
}
};
d.ondblclick = ()=>{
stopScroll();
d.scrollTop = 0;
};
})();
// bookmarklet: 网页自动滚动 - 平滑版
翻页版
鉴于长时间注视持续移动的文字可能视觉疲劳,所以建议使用翻页版。
-
stepTime
是间隔多少毫秒翻到下一屏(1000毫秒 = 1秒); -
overlap
是两屏内容重叠的高度,如果页面有悬浮导航建议适当调大; - 点书签开始滚动(不是立刻下一屏,要等待间隔时间之后才到下一屏;
- 点网页空白处切换滚动状态(开始/停止);
- 双击网页空白返回顶部
javascript: (function () {
const d = document.documentElement;
const stepTime = 5000;
const overlap = 80;
const scroll = {};
const stopScroll = ()=>{
scroll.state = false;
scroll.time = null;
};
stopScroll();
const scrollThisPage = (timestamp)=>{
if(scroll.time){
if((timestamp - scroll.time)>=stepTime){
d.scrollTop += window.innerHeight - overlap;
scroll.time = timestamp;
}
}else{
scroll.time = timestamp;
}
if(d.scrollTop < d.scrollHeight-window.innerHeight-10 && scroll.state){
window.requestAnimationFrame(scrollThisPage);
}else{
stopScroll();
}
};
scroll.state = true;
window.requestAnimationFrame(scrollThisPage);
d.onclick = ()=>{
if(scroll.state){
stopScroll();
}else{
scroll.state = true;
window.requestAnimationFrame(scrollThisPage);
}
};
d.ondblclick = ()=>{
stopScroll();
d.scrollTop = 0;
};
})();
// bookmarklet: 网页自动滚动 - 翻页版