-
Notifications
You must be signed in to change notification settings - Fork 0
/
Auto scroller.user.js
32 lines (32 loc) · 965 Bytes
/
Auto scroller.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// ==UserScript==
// @name Auto scroller
// @namespace https://greasyfork.org/zh-TW/users/11333-bendwarn
// @version 0.1
// @description use alt= to scroll down, alt- to scroll up(both can be faster by pressing more), and alt+0 to stop.
// @author bendwarn
// @match *://*/*
// @run-at document-idle
// @license MIT License
// ==/UserScript==
let intervalid = null
let time = 16
let speed = 0
let move = _ => {document.body.scrollTop += speed}
document.body.onkeydown = e => {
if (e.altKey) {
let key = e.key
if (key == '+' || key == '=' || key == '-') {
speed += (key == '-') ? -2 : 2
if (intervalid === null) intervalid = setInterval(move, time)
else {
clearInterval(intervalid)
if (speed) intervalid = setInterval(move, time)
else intervalid = null
}
} else if (key == '0') {
clearInterval(intervalid)
intervalid = null
speed = 0
}
}
}