WhaleScroll

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

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