lazyScroller (beta)

Keep your hand free from scroll button.

Ekde 2015/01/06. Vidu La ĝisdata versio.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

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.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         lazyScroller (beta)
// @version      0.21
// @description  Keep your hand free from scroll button.
// @namespace    idmresettrial
// @author       idmresettrial
// @run-at       document-end
// @grant        none

// @require     http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js

// Website list

// @match        *://*.vozforums.com/*

// End list


// ==/UserScript==

wait = 500;
distance = $(window).height()-20;
duration = 300;
pause = 1000;
var repeat;
direct = "out";


lazyScroller = '<div id="lazyScroller"><div class="lazyButton" id="lazyUp">↑</div><div class="lazyButton" id="lazyDown">↓</div></div>';

$("body").append(lazyScroller);
$("#lazyScroller").attr("style","position:fixed; top:0px; left:0px; margin:10px; z-index:999;");
$(".lazyButton").attr("style","margin:0px; width:20px; height:20px; font-size:10px; color:#fff;line-height:20px;text-align:center;background:rgba(248, 72, 72, 0.5)");

$(document).on("mousemove",function(e) {
    if (Math.abs(parseInt($("#lazyScroller").css("left"))-e.clientX)>50 || Math.abs(parseInt($("#lazyScroller").css("top"))-e.clientY)>100) {
        $("#lazyScroller").css({"left": e.clientX, "top": e.clientY});
    }
});


$("#lazyScroller .lazyButton").mouseover(function() {
    direct = $(this).attr("id");
    setTimeout(function() {go();},wait);
    $(this).css({"background": "#f84848"});
});

$("#lazyScroller .lazyButton").mouseout(function() {
    direct = "out";
    clearTimeout(repeat);
    $(this).css({"background": "rgba(248, 72, 72, 0.4)"});
});

$("#lazyScroller #lazyUp").click(function() {
    direct = "top";
    $("body").scrollTop(0);
});

$("#lazyScroller #lazyDown").click(function() {
    direct = "back";
    history.go(-1);
});


function go()
{
    if (direct === "lazyUp") {
        $("body").animate({scrollTop: ($("body").scrollTop()-distance)}, duration);
        repeat = setTimeout(function() {go();},duration+pause);
    } else if (direct === "lazyDown") {
        $("body").animate({scrollTop: ($("body").scrollTop()+distance)}, duration);
        repeat = setTimeout(function() {go();},duration+pause);
    } else clearTimeout(repeat);
}