WhaleScroll

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

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==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);