Optimize Browser

Have a better experience to use browser.

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         Optimize Browser
// @namespace    http://tampermonkey.net/
// @version      1.1.0
// @description  Have a better experience to use browser.
// @author       Eugene Liu
// @match        *://*/*
// ==/UserScript==

(function () {//Ignore MouseWheel,only care key and mouse.
    var timerID;
    var timeout;
    var speed = 50;
    var EugeneScroll;
    var stopAutoScroll = false;

    document.onkeydown = function (event) {
        var e = event || window.event || arguments.callee.caller.arguments[0];
        if (e && e.keyCode == 118) {
            if (stopAutoScroll === false) {
                stopAutoScroll = true;
            } else {
                stopAutoScroll = false;
            }
        }
    };

    function ScreenSaver(settings) {
        timeout = settings.timeout;
        document.body.onmousemove = document.body.onmousedown = document.body.onkeydown = document.body.onkeypress = ScreenSaver.prototype.onevent;
        timerID = window.setTimeout(function () {
            if (!stopAutoScroll) {
                moveDown();
            }
        }, timeout);
    }

    ScreenSaver.prototype.onevent = function (e) {
        window.clearTimeout(timerID);
        stopMove();
        timerID = window.setTimeout(function () {
            if (!stopAutoScroll) {
                moveDown();
            }
        }, timeout);
    };

    function initScreenSaver() {
        new ScreenSaver({timeout: 5000});
    }

    function moveDown() {
        EugeneScroll = setInterval(function () {
            window.scrollBy(0, +1);
        }, speed);
    }

    function stopMove() {
        clearInterval(EugeneScroll);
    }

    window.onload = function () {
        initScreenSaver();
    }
})();