WhaleScroll

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

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

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

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

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