lazyScroller (beta)

Keep your hand free from scroll button.

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

  1. // ==UserScript==
  2. // @name lazyScroller (beta)
  3. // @version 0.24
  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 http://vozforums.com/*
  15.  
  16. // End list
  17.  
  18.  
  19. // ==/UserScript==
  20.  
  21. red = "#f84848"; green = "#7abf16"; blue = "#3e68b3";
  22. color = blue;
  23.  
  24. transparent = 0.5;
  25.  
  26. distance = $(window).height()-50;
  27. duration = 500;
  28.  
  29. wait = 500;
  30. pause = 1000;
  31. var repeat;
  32.  
  33. direct = "lazySleep";
  34.  
  35. lazyScroller = '<div id="lazyScroller"><div class="lazyButton" id="lazyUp">↑</div><div class="lazyButton" id="lazyDown">↓</div></div>';
  36.  
  37. $("body").append(lazyScroller);
  38. $("#lazyScroller").css({"cursor":"default", "position":"fixed", "top":"-100px", "left":"-100px", "margin":"10px", "z-index":"999"});
  39. $(".lazyButton").css({"margin":"5px", "width":"20px", "height":"20px", "font-family":"calibri", "font-size":"12px", "line-height":"20px", "text-align":"center", "background":color, "color":"#FFFFFF"});
  40. $(".lazyButton").fadeTo(0, transparent);
  41.  
  42. $(document).on("mousemove",function(e) {
  43. if (Math.abs(parseInt($("#lazyScroller").css("left"))-e.clientX)>50 || Math.abs(parseInt($("#lazyScroller").css("top"))-e.clientY)>100) {
  44. $("#lazyScroller").css({"left":e.clientX, "top":e.clientY, "display":"none"});
  45. } else {
  46. if ($('body').scrollTop() === 0) {
  47. $("#lazyUp").html("→");
  48. } else if ($('body').scrollTop() === ($(document).height()-$(window).height())) {
  49. $("#lazyDown").html("←");
  50. } else {
  51. $("#lazyUp").html("↑");
  52. $("#lazyDown").html("↓");
  53. }
  54. $("#lazyScroller").fadeIn();
  55. }
  56. });
  57.  
  58.  
  59. $("#lazyScroller .lazyButton").mouseover(function() {
  60. direct = $(this).attr("id");
  61. $(this).fadeTo(500, 1);
  62. setTimeout(function() {go();},wait);
  63. });
  64.  
  65. $("#lazyScroller .lazyButton").mouseout(function() {
  66. direct = "lazySleep";
  67. $(this).fadeTo(500, transparent);
  68. clearTimeout(repeat);
  69. });
  70.  
  71. $("#lazyScroller #lazyUp").click(function() {
  72. if ($('body').scrollTop() === 0) {
  73. direct = "lazyNext";
  74. } else {
  75. direct = "lazyTop";
  76. }
  77. go();
  78. });
  79.  
  80. $("#lazyScroller #lazyDown").click(function() {
  81. if ($('body').scrollTop() === ($(document).height()-$(window).height())) {
  82. direct = "lazyBack";
  83. } else {
  84. direct = "lazyBottom";
  85. }
  86. go();
  87. });
  88.  
  89. function go()
  90. {
  91. if (direct === "lazyUp") {
  92. $("body").animate({scrollTop: ($("body").scrollTop()-distance)}, duration);
  93. repeat = setTimeout(function() {go();},duration+pause);
  94. } else if (direct === "lazyDown") {
  95. $("body").animate({scrollTop: ($("body").scrollTop()+distance)}, duration);
  96. repeat = setTimeout(function() {go();},duration+pause);
  97. } else if (direct === "lazyTop") {
  98. $("body").animate({scrollTop: 0},duration);
  99. } else if (direct === "lazyBottom") {
  100. $("body").animate({scrollTop: ($(document).height()-$(window).height())},duration);
  101. } else if (direct === "lazyNext") {
  102. history.go(+1);
  103. } else if (direct === "lazyBack") {
  104. history.go(-1);
  105. } else {
  106. clearTimeout(repeat);
  107. }
  108. }

QingJ © 2025

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