WhaleScroll

双击切换自动滚屏 - 基于AutoScroll by OscarKoo

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name        WhaleScroll
// @namespace   https://greasyfork.org/zh-CN/users/1337574-mirakelor
// @description 双击切换自动滚屏 - 基于AutoScroll by OscarKoo
// @match             *://*/*
// @version     2024.07.22
// @author      Mirakelor
// @license MIT
// ==/UserScript==

(function(document) {

  var scrollingEnabled = false;
  var scrollTimerId = 0;


  /**
   * 处理双击事件:反转滚动状态并触发滚动逻辑。
   */
  var toggleScroll = function() {
    scrollingEnabled = !scrollingEnabled;
    clearTimeout(scrollTimerId);
    if (scrollingEnabled) startScroll();
  };



  /**
   * 实现自动滚屏,每间隔一定的延迟进行滚动操作。
   */
  var startScroll = function() {

    window.scrollTo(0, window.scrollY + 1);
    scrollTimerId = setTimeout(startScroll, 15); // 可配置滚动速度
  };




  // 将双击事件与处理函数绑定,注意使用一次移除旧事件
  document.body.removeEventListener('dblclick', toggleScroll);
  document.body.addEventListener('dblclick', toggleScroll);

})(document);