上下翻页按钮

添加浮动按钮以进行上下翻页。

  1. // ==UserScript==
  2. // @name 上下翻页按钮
  3. // @version 1.2
  4. // @description 添加浮动按钮以进行上下翻页。
  5. // @author ChatGPT
  6. // @match *://*/*
  7. // @run-at document-end
  8. // @grant none
  9. // @namespace https://gf.qytechs.cn/users/452911
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. // 创建上翻按钮
  16. const upButton = document.createElement('div');
  17. upButton.innerText = '△';
  18. upButton.style.position = 'fixed';
  19. upButton.style.right = '10px';
  20. upButton.style.top = '40%'; // 调整位置,缩短间隔
  21. upButton.style.width = '40px';
  22. upButton.style.height = '40px';
  23. upButton.style.backgroundColor = 'rgba(255, 255, 255, 0.5)'; // 半透明背景
  24. upButton.style.borderRadius = '5px';
  25. upButton.style.textAlign = 'center';
  26. upButton.style.lineHeight = '40px';
  27. upButton.style.cursor = 'pointer';
  28. upButton.style.zIndex = '9999';
  29. upButton.style.color = 'rgba(0, 0, 0, 0.5)'; // 半透明字体颜色
  30.  
  31. // 创建下翻按钮
  32. const downButton = document.createElement('div');
  33. downButton.innerText = '▽';
  34. downButton.style.position = 'fixed';
  35. downButton.style.right = '10px';
  36. downButton.style.top = '55%'; // 调整位置,缩短间隔
  37. downButton.style.width = '40px';
  38. downButton.style.height = '40px';
  39. downButton.style.backgroundColor = 'rgba(255, 255, 255, 0.5)'; // 半透明背景
  40. downButton.style.borderRadius = '5px';
  41. downButton.style.textAlign = 'center';
  42. downButton.style.lineHeight = '40px';
  43. downButton.style.cursor = 'pointer';
  44. downButton.style.zIndex = '9999';
  45. downButton.style.color = 'rgba(0, 0, 0, 0.5)'; // 半透明字体颜色
  46.  
  47. // 添加事件监听器
  48. upButton.addEventListener('click', () => {
  49. window.scrollBy(0, -window.innerHeight * 0.8); // 向上滚动80%
  50. });
  51.  
  52. downButton.addEventListener('click', () => {
  53. window.scrollBy(0, window.innerHeight * 0.8); // 向下滚动80%
  54. });
  55.  
  56. // 将按钮添加到文档中
  57. document.body.appendChild(upButton);
  58. document.body.appendChild(downButton);
  59. })();

QingJ © 2025

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