lazyScroller (beta)

Keep your hand free from scroll button.

Tính đến 06-01-2015. Xem phiên bản mới nhất.

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

Bạn sẽ cần cài đặt một tiện ích mở rộng như Tampermonkey hoặc Violentmonkey để cài đặt kịch bản này.

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.

(Tôi đã có Trình quản lý tập lệnh người dùng, hãy cài đặt nó!)

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.23
// @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        http://vozforums.com/*

// End list


// ==/UserScript==

red = "#f84848"; green = "#7abf16"; blue = "#3e68b3";
color = blue;

transparent = 0.5;

distance = $(window).height()-50;
duration = 500;

wait = 500;
pause = 1000;
var repeat;

direct = "lazySleep";

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

$("body").append(lazyScroller);
$("#lazyScroller").css({"position":"fixed", "top":"-100px", "left":"-100px", "margin":"10px", "z-index":"999"});
$(".lazyButton").css({"margin":"5px", "width":"20px", "height":"20px", "font-family":"calibri", "font-size":"12px", "line-height":"20px", "text-align":"center", "background":color, "color":"#FFFFFF"});
$(".lazyButton").fadeTo(0, transparent);

$(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, "display":"none"});
    } else {
        $("#lazyScroller").fadeIn();
    }
});


$("#lazyScroller .lazyButton").mouseover(function() {
    direct = $(this).attr("id");
    setTimeout(function() {go();},wait);
    $(this).fadeTo(500, 1);
});

$("#lazyScroller .lazyButton").mouseout(function() {
    direct = "lazySleep";
    clearTimeout(repeat);
    $(this).fadeTo(500, transparent);
});

$("#lazyScroller #lazyUp").click(function() {
    direct = "lazyTop";
    $("body").animate({scrollTop: 0},duration);
});

$("#lazyScroller #lazyDown").click(function() {
    direct = "lazyBack";
    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);
    }
}