AutoScroll avec boutons tactiles pour mobiles et tablettes
Verzia zo dňa
// ==UserScript==
// @name AutoScroll Mobile
// @namespace https://greasyfork.org/users/1429467
// @description AutoScroll avec boutons tactiles pour mobiles et tablettes
// @include http*
// @version 1.1
// @author Lakfu sama
// @grant none
// ==/UserScript==
(function() {
'use strict';
let scrolling = false;
let speed = 50;
let scrollInterval;
function startScrolling() {
if (!scrolling) {
scrolling = true;
scrollInterval = setInterval(() => {
window.scrollBy(0, 5);
}, speed);
updateButtonState();
}
}
function stopScrolling() {
scrolling = false;
clearInterval(scrollInterval);
updateButtonState();
}
function toggleScrolling() {
scrolling ? stopScrolling() : startScrolling();
}
function increaseSpeed() {
if (speed > 10) {
speed -= 10;
restartScrolling();
}
}
function decreaseSpeed() {
speed += 10;
restartScrolling();
}
function restartScrolling() {
if (scrolling) {
stopScrolling();
startScrolling();
}
}
function scrollToTop() {
window.scrollTo({ top: 0, behavior: 'smooth' });
}
function scrollToBottom() {
window.scrollTo({ top: document.body.scrollHeight, behavior: 'smooth' });
}
function updateButtonState() {
let button = document.getElementById('scroll-toggle');
if (scrolling) {
button.textContent = '⏸️ Stop';
button.style.backgroundColor = '#ff5555';
} else {
button.textContent = '▶️ Start';
button.style.backgroundColor = '#4CAF50';
}
}
// Création des boutons tactiles
function createButton(id, text, onClick, bgColor) {
let button = document.createElement('button');
button.id = id;
button.textContent = text;
button.onclick = onClick;
button.style.position = 'fixed';
button.style.bottom = '10px';
button.style.right = (10 + document.querySelectorAll('.scroll-btn').length * 60) + 'px';
button.style.padding = '10px';
button.style.fontSize = '16px';
button.style.border = 'none';
button.style.borderRadius = '10px';
button.style.backgroundColor = bgColor;
button.style.color = 'white';
button.style.zIndex = '10000';
button.className = 'scroll-btn';
document.body.appendChild(button);
return button;
}
createButton('scroll-toggle', '▶️ Start', toggleScrolling, '#4CAF50');
createButton('scroll-up', '⬆️', scrollToTop, '#2196F3');
createButton('scroll-down', '⬇️', scrollToBottom, '#2196F3');
createButton('speed-up', '⏩+', increaseSpeed, '#FF9800');
createButton('speed-down', '⏪-', decreaseSpeed, '#FF9800');
})();