Greasy Fork镜像 支持简体中文。

滑动器6

控制网页自动向上滑动的速度

  1. // ==UserScript==
  2. // @name 滑动器6
  3. // @namespace your-namespace
  4. // @version 1.0
  5. // @description 控制网页自动向上滑动的速度
  6. // @author Your Name
  7. // @match http://www.htmanga3.top/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. if (location.href.indexOf('https://www.baidu.com/s') == 0 || location.href.indexOf('http://www.baidu.com/s') == 0) {
  12. var jq = jQuery.noConflict();
  13. Compatible(jq);
  14. var chaoxing = false;
  15. } else if (location.href.indexOf('chaoxing') != -1) {
  16. var jq = jQuery.noConflict();
  17. Compatible(jq);
  18. var chaoxing = true;
  19. } else {
  20. Compatible(jQuery);
  21. var chaoxing = false;
  22. }
  23.  
  24. function Compatible(jq) {
  25. var box = jq('<div class="move-box"><input type="number" class="move-val" value="1" title="速度"/><p class="start" title="开始/暂停">▶</p><p class="reverse" title="反方向">▼</p></div>');
  26. jq('body').append(box);
  27.  
  28. (function () {
  29. jq('.move-box').css({
  30. 'width': '40px',
  31. 'height': '90px',
  32. 'background': '#fff',
  33. 'box-shadow': '0 0 4px 0 #ccc',
  34. 'border-radius': '8px',
  35. 'user-select': 'none',
  36. 'overflow': 'hidden',
  37. 'position': 'fixed',
  38. 'top': '80px',
  39. 'left': '4px',
  40. 'z-index': 99999999
  41. });
  42. jq('.move-val').css({
  43. 'width': '100%',
  44. 'height': '30px',
  45. 'padding': 0,
  46. 'color': '#000',
  47. 'border': 'none',
  48. 'outline': 'none',
  49. 'font-size': '18px',
  50. 'text-align': 'center'
  51. })
  52. jq('.start').css({
  53. 'margin': 0,
  54. 'width': '100%',
  55. 'height': '30px',
  56. 'line-height': '30px',
  57. 'text-align': 'center',
  58. 'background': 'red',
  59. 'color': '#fff',
  60. 'font-size': '20px',
  61. 'cursor': 'pointer'
  62. })
  63. jq('.reverse').css({
  64. 'margin': 0,
  65. 'width': '100%',
  66. 'height': '30px',
  67. 'line-height': '30px',
  68. 'text-align': 'center',
  69. 'color': '#ccc',
  70. 'cursor': 'pointer'
  71. })
  72. }())
  73.  
  74. var elinput = document.getElementsByClassName('move-val')[0],
  75. elstart = document.getElementsByClassName('start')[0],
  76. elreverse = document.getElementsByClassName('reverse')[0],
  77. speed = 1,
  78. isMove = false,
  79. isHide = true,
  80. flag = false,
  81. lookTop = 0,
  82. timers = null,
  83. scrollTimer = null; // 新增定时器
  84.  
  85. // Listen for double tap events
  86. var clickCount = 0;
  87. var lastClickTime, timeoutId;
  88. function handleClick() {
  89. clickCount++;
  90. if (clickCount === 1) {
  91. lastClickTime = new Date().getTime();
  92. timeoutId = setTimeout(function () {
  93. clickCount = 0;
  94. }, 300);
  95. } else if (clickCount === 2) {
  96. clearTimeout(timeoutId);
  97. clickCount = 0;
  98. elstart.click(); // trigger scrolling function
  99. }
  100. }
  101.  
  102. window.addEventListener('touchstart', handleClick);
  103.  
  104. elinput.oninput = setIn;
  105.  
  106. function setIn() {
  107. if (this.value > 10) {
  108. this.value = 10;
  109. }
  110. if (this.value < -10) {
  111. this.value = -10;
  112. }
  113. if (this.value == '') {
  114. this.value = 0;
  115. }
  116. speed = Number(this.value);
  117. speed < 0 ? elreverse.innerText = '▲' : elreverse.innerText = '▼';
  118. }
  119.  
  120. elstart.onclick = function () {
  121. if (isMove) {
  122. this.innerText = '▶';
  123. flag = false;
  124. isMove = false;
  125. isHide = true;
  126. clearTimeout(scrollTimer); // 停止滚动定时器
  127. } else {
  128. this.innerText = '◉';
  129. flag = true;
  130. isMove = true;
  131. isHide = false;
  132. move(); // 开始滚动
  133. }
  134. hideShow();
  135. }
  136.  
  137. elreverse.onclick = function () {
  138. speed = -speed;
  139. speed < 0 ? this.innerText = '▲' : this.innerText = '▼';
  140. }
  141.  
  142. function move() {
  143. if (flag) {
  144. var imglook = jq('.imglook');
  145. if (imglook.length === 0) {
  146. window.scrollBy(0, speed);
  147. if (chaoxing && jq(window).height() + jq(window).scrollTop() >= jq(document).height() - 180) {
  148. if ($('#loadbutton').length == 1) {
  149. clearTimeout(timers);
  150. $('#loadbutton').click();
  151. timers = setTimeout(() => {
  152. isMove ? '' : elstart.click()
  153. }, 200)
  154. }
  155. }
  156. if (jq(window).height() + jq(window).scrollTop() >= jq(document).height() - 2 || jq(window).scrollTop() == 0) {
  157. elstart.innerText = '▶';
  158. flag = false;
  159. isMove = false;
  160. isHide = true;
  161. hideShow();
  162. return; // 结束滚动
  163. }
  164. } else {
  165. // 超新课程资料文件预览
  166. var loopNum = 0
  167. lookTop = imglook[0].scrollTop
  168. imglook[0].scrollBy(0, speed)
  169. function loopTest() {
  170. loopNum++
  171. setTimeout(() => {
  172. if (imglook[0].scrollTop === lookTop) {
  173. loopTest()
  174. if (loopNum > 6) {
  175. elstart.innerText = '▶';
  176. flag = false;
  177. isMove = false;
  178. isHide = true;
  179. hideShow();
  180. return; // 结束滚动
  181. }
  182. }
  183. }, 200)
  184. }
  185. if (imglook[0].scrollTop === lookTop) {
  186. loopTest()
  187. }
  188. }
  189.  
  190. // 滚动结束后停止1秒,再次启动滚动
  191. clearTimeout(scrollTimer);
  192. scrollTimer = setTimeout(function () {
  193. move();
  194. }, 2000);
  195. }
  196. }
  197.  
  198. jq(document).keydown((e) => {
  199. var event = e || window.event;
  200. if (event.keyCode == 32) {
  201. elstart.click();
  202. return false;
  203. }
  204. if (event.keyCode == 38) {
  205. elinput.value++;
  206. }
  207. if (event.keyCode == 40) {
  208. elinput.value--;
  209. }
  210. setIn.call(elinput);
  211. })
  212.  
  213. // 隐藏
  214. hideShow()
  215.  
  216. function hideShow() {
  217. // if(!isHide) return;
  218. var timer2 = null;
  219.  
  220. function hide() {
  221. jq('.move-box').stop().animate({
  222. 'left': '-30px'
  223. }, 400)
  224. }
  225.  
  226. timer2 = setTimeout(hide, 6000);
  227.  
  228. jq('.move-box').hover(function () {
  229. // if(!isHide) return;
  230. clearInterval(timer2);
  231. jq(this).stop().animate({
  232. 'left': '4px'
  233. }, 600)
  234. }, function () {
  235. // if(!isHide) return;
  236. timer2 = setTimeout(hide, 6000);
  237. })
  238. }
  239. }

QingJ © 2025

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