lazyScroller (beta)

Keep your hand free from scroll button.

当前为 2015-01-06 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name lazyScroller (beta)
  3. // @version 0.2
  4. // @description Keep your hand free from scroll button.
  5. // @namespace idmresettrial
  6. // @author idmresettrial
  7. // @run-at document-end
  8. // @grant none
  9.  
  10. // @require http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js
  11.  
  12. // Website list
  13.  
  14. // @match *://*.vozforums.com/*
  15.  
  16. // End list
  17.  
  18.  
  19. // ==/UserScript==
  20.  
  21. wait = 1000;
  22. distance = $(window).height()-20;
  23. duration = 300;
  24. pause = 5000;
  25. var repeat;
  26. direct = "out";
  27.  
  28.  
  29. lazyScroller = '<div id="lazyScroller"><div class="lazyButton" id="lazyUp">↑</div><div class="lazyButton" id="lazyDown">↓</div></div>';
  30.  
  31. $("body").append(lazyScroller);
  32. $("#lazyScroller").attr("style","position:fixed; top:0px; left:0px; margin:10px; z-index:999;");
  33. $(".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)");
  34.  
  35. $(document).on("mousemove",function(e) {
  36. if (Math.abs(parseInt($("#lazyScroller").css("left"))-e.clientX)>50 || Math.abs(parseInt($("#lazyScroller").css("top"))-e.clientY)>100) {
  37. $("#lazyScroller").css({"left": e.clientX, "top": e.clientY});
  38. }
  39. });
  40.  
  41.  
  42. $("#lazyScroller .lazyButton").mouseover(function() {
  43. direct = $(this).attr("id");
  44. setTimeout(function() {go();},wait);
  45. $(this).css({"background": "#f84848"});
  46. });
  47.  
  48. $("#lazyScroller .lazyButton").mouseout(function() {
  49. direct = "out";
  50. clearTimeout(repeat);
  51. $(this).css({"background": "rgba(248, 72, 72, 0.4)"});
  52. });
  53.  
  54. $("#lazyScroller #lazyUp").click(function() {
  55. direct = "top";
  56. $("body").scrollTop(0);
  57. });
  58.  
  59. $("#lazyScroller #lazyDown").click(function() {
  60. direct = "back";
  61. history.go(-1);
  62. });
  63.  
  64.  
  65. function go()
  66. {
  67. if (direct === "lazyUp") {
  68. $("body").animate({scrollTop: ($("body").scrollTop()-distance)}, duration);
  69. repeat = setTimeout(function() {go();},duration+pause);
  70. } else if (direct === "lazyDown") {
  71. $("body").animate({scrollTop: ($("body").scrollTop()+distance)}, duration);
  72. repeat = setTimeout(function() {go();},duration+pause);
  73. } else clearTimeout(repeat);
  74. }

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址