Website AutoScroll

Automatically scroll through any webpage!

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name         Website AutoScroll
// @namespace    http://tampermonkey.net/
// @version      1.1
// @description  Automatically scroll through any webpage!
// @author       Calvin H
// @match        *://*/*
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    var minClamp = 1;
    var maxClamp = 10000; // Change this to modify max possible pixels per second

    var popupVariable;
    var pixelsPerFrame = 1;

    var scrollState = true;

    window.addEventListener('keydown', function(event) {
        if (event.keyCode === 72 && (event.ctrlKey || event.metaKey)) {
            popupVariable = prompt("How many pixels per second would you like to AutoScroll? (" + minClamp + "-" + maxClamp + "). Just manually scroll in order to stop the AutoScroll.");
            scrollState = false;
            popupVariable = clamp(popupVariable);
            scrollInterval = 1000/popupVariable;
            pixelsPerFrame = 1;
            if (popupVariable > 100) {
                scrollInterval = 10;
                pixelsPerFrame = popupVariable/100
            }
            clearInterval(scrollIntervalId);
            scrollIntervalId = window.setInterval(scrollDown, scrollInterval);
        }
    }, false);

    var scrollIntervalId;
    var scrollInterval;

    function scrollDown() {
        if (!scrollState) {
        window.scrollBy(0, pixelsPerFrame);
            console.log(pixelsPerFrame);
        }
    }

    function clamp(num) {
        return Math.max(minClamp, Math.min(num, maxClamp));
    }

    window.addEventListener('wheel', function(e) {
        if (!scrollState) {
            scrollState = true;
        }
    }, false);
})();