🏠 Home 

上下翻页按钮

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


安装此脚本?
  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://greasyfork.org/users/452911
  10. // ==/UserScript==
  11. (function() {
  12. 'use strict';
  13. // 创建上翻按钮
  14. const upButton = document.createElement('div');
  15. upButton.innerText = '△';
  16. upButton.style.position = 'fixed';
  17. upButton.style.right = '10px';
  18. upButton.style.top = '40%'; // 调整位置,缩短间隔
  19. upButton.style.width = '40px';
  20. upButton.style.height = '40px';
  21. upButton.style.backgroundColor = 'rgba(255, 255, 255, 0.5)'; // 半透明背景
  22. upButton.style.borderRadius = '5px';
  23. upButton.style.textAlign = 'center';
  24. upButton.style.lineHeight = '40px';
  25. upButton.style.cursor = 'pointer';
  26. upButton.style.zIndex = '9999';
  27. upButton.style.color = 'rgba(0, 0, 0, 0.5)'; // 半透明字体颜色
  28. // 创建下翻按钮
  29. const downButton = document.createElement('div');
  30. downButton.innerText = '▽';
  31. downButton.style.position = 'fixed';
  32. downButton.style.right = '10px';
  33. downButton.style.top = '55%'; // 调整位置,缩短间隔
  34. downButton.style.width = '40px';
  35. downButton.style.height = '40px';
  36. downButton.style.backgroundColor = 'rgba(255, 255, 255, 0.5)'; // 半透明背景
  37. downButton.style.borderRadius = '5px';
  38. downButton.style.textAlign = 'center';
  39. downButton.style.lineHeight = '40px';
  40. downButton.style.cursor = 'pointer';
  41. downButton.style.zIndex = '9999';
  42. downButton.style.color = 'rgba(0, 0, 0, 0.5)'; // 半透明字体颜色
  43. // 添加事件监听器
  44. upButton.addEventListener('click', () => {
  45. window.scrollBy(0, -window.innerHeight * 0.8); // 向上滚动80%
  46. });
  47. downButton.addEventListener('click', () => {
  48. window.scrollBy(0, window.innerHeight * 0.8); // 向下滚动80%
  49. });
  50. // 将按钮添加到文档中
  51. document.body.appendChild(upButton);
  52. document.body.appendChild(downButton);
  53. })();