连续点击加速.单击停止
当前为
// ==UserScript==
// @name Ctrl点击滚动
// @description 连续点击加速.单击停止
// @version 1
// @match *
// @namespace https://greasyfork.org/users/12375
// ==/UserScript==
(function() {
let isScrolling = false;
document.body.addEventListener('click', stopScroll);
document.body.addEventListener('click', function(event) {
if (event.ctrlKey || event.metaKey) { // 检查是否按下了 Ctrl 或 Command 键
event.preventDefault(); // 阻止默认行为(如果有的话)
startScroll(); // 开始滚动
}
});
function stopScroll() {
isScrolling = false;
}
function startScroll() {
isScrolling = true;
scroll();
}
function scroll() {
if (isScrolling) {
window.scrollBy(0, 5);
requestAnimationFrame(scroll);
}
}
})();