AutoScroll Mobile

AutoScroll avec boutons tactiles pour mobiles et tablettes

目前为 2025-01-31 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name AutoScroll Mobile
  3. // @namespace https://greasyfork.org/users/1429467
  4. // @description AutoScroll avec boutons tactiles pour mobiles et tablettes
  5. // @include http*
  6. // @version 1.1
  7. // @author Lakfu sama
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. let scrolling = false;
  15. let speed = 50;
  16. let scrollInterval;
  17.  
  18. function startScrolling() {
  19. if (!scrolling) {
  20. scrolling = true;
  21. scrollInterval = setInterval(() => {
  22. window.scrollBy(0, 5);
  23. }, speed);
  24. updateButtonState();
  25. }
  26. }
  27.  
  28. function stopScrolling() {
  29. scrolling = false;
  30. clearInterval(scrollInterval);
  31. updateButtonState();
  32. }
  33.  
  34. function toggleScrolling() {
  35. scrolling ? stopScrolling() : startScrolling();
  36. }
  37.  
  38. function increaseSpeed() {
  39. if (speed > 10) {
  40. speed -= 10;
  41. restartScrolling();
  42. }
  43. }
  44.  
  45. function decreaseSpeed() {
  46. speed += 10;
  47. restartScrolling();
  48. }
  49.  
  50. function restartScrolling() {
  51. if (scrolling) {
  52. stopScrolling();
  53. startScrolling();
  54. }
  55. }
  56.  
  57. function scrollToTop() {
  58. window.scrollTo({ top: 0, behavior: 'smooth' });
  59. }
  60.  
  61. function scrollToBottom() {
  62. window.scrollTo({ top: document.body.scrollHeight, behavior: 'smooth' });
  63. }
  64.  
  65. function updateButtonState() {
  66. let button = document.getElementById('scroll-toggle');
  67. if (scrolling) {
  68. button.textContent = '⏸️ Stop';
  69. button.style.backgroundColor = '#ff5555';
  70. } else {
  71. button.textContent = '▶️ Start';
  72. button.style.backgroundColor = '#4CAF50';
  73. }
  74. }
  75.  
  76. // Création des boutons tactiles
  77. function createButton(id, text, onClick, bgColor) {
  78. let button = document.createElement('button');
  79. button.id = id;
  80. button.textContent = text;
  81. button.onclick = onClick;
  82. button.style.position = 'fixed';
  83. button.style.bottom = '10px';
  84. button.style.right = (10 + document.querySelectorAll('.scroll-btn').length * 60) + 'px';
  85. button.style.padding = '10px';
  86. button.style.fontSize = '16px';
  87. button.style.border = 'none';
  88. button.style.borderRadius = '10px';
  89. button.style.backgroundColor = bgColor;
  90. button.style.color = 'white';
  91. button.style.zIndex = '10000';
  92. button.className = 'scroll-btn';
  93. document.body.appendChild(button);
  94. return button;
  95. }
  96.  
  97. createButton('scroll-toggle', '▶️ Start', toggleScrolling, '#4CAF50');
  98. createButton('scroll-up', '⬆️', scrollToTop, '#2196F3');
  99. createButton('scroll-down', '⬇️', scrollToBottom, '#2196F3');
  100. createButton('speed-up', '⏩+', increaseSpeed, '#FF9800');
  101. createButton('speed-down', '⏪-', decreaseSpeed, '#FF9800');
  102.  
  103. })();