Autoscroll

Autoscroll any page

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        Autoscroll
// @namespace   Autoscroll
// @description Autoscroll any page
// @version     1
// @grant       none
// @include     *
// @license     MIT
// ==/UserScript==

(function() {
var scrollInterval = null; // Time interval automatically set, to autoscroll
var scrollTimer = 5; // Time (in ms) between each 1px scroll (default to 10ms)
var scrollPixels = 1; // Number of pixels scrolled (default to 1)
var scrollIncrement = 2; // Time increment (in ms) to add/substract to the current autoscroll (default to 2ms)
var startKey = ":"; // Bind to (re)start the script (default to ":")
var stopKey = "s"; // Bind to stop the script (default to "s")
var fasterKey = "+"; // Bind to accelerate the autoscroll (default to "+")
var slowerKey = "-"; // Bind to slowdown the autoscroll (default to "-")

// Scroll the page by 1px vertically (for smooth scrolling)
function pageScroll() {
    window.scrollBy(0,scrollPixels);
}
  
// Reset the scroll interval
function resetScroll() {
  clearInterval(scrollInterval);
  scrollInterval = setInterval(pageScroll, scrollTimer);
}
  
// Keystrokes
var previousKeyStroke = null;
function keyStrokes(event) {
  if (document.activeElement.localName == "input") return;
  var ek = event.key;
  var tmpPreviousKeyStroke = previousKeyStroke;
  previousKeyStroke = ek;
  if (tmpPreviousKeyStroke == "Control") return;
  switch (ek) {
    case startKey:
      console.log("(Re)started");
      resetScroll();
      break;
    case stopKey:
      console.log("Stopped");
      clearInterval(scrollInterval);
      break;
    case fasterKey:
      scrollTimer -= scrollIncrement;
      if (scrollTimer <= 0) {
		scrollTimer = 1;
		scrollPixels++;
	  }
      resetScroll();
      break;
    case slowerKey:
      (scrollPixels > 1) ? scrollPixels-- : scrollTimer += scrollIncrement;
	  resetScroll();
      break;
    default:
  }
}
document.onkeydown = keyStrokes;

})();