Auto Scroll Up & Down

Auto-scroll any page. Press "S" to scroll down, Shift+S to scroll up. Use ↑ and ↓ to adjust speed in real time.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name         Auto Scroll Up & Down
// @namespace    http://tampermonkey.net/
// @version      2.2
// @description  Auto-scroll any page. Press "S" to scroll down, Shift+S to scroll up. Use ↑ and ↓ to adjust speed in real time.
// @author       Syntax-Surfer-1
// @match        *://*/*
// @grant        none
// ==/UserScript==

(function () {
    'use strict';

    let isScrolling = false;
    let scrollInterval = null;
    let scrollDirection = 1;
    let scrollSpeed = 20;
    const SCROLL_STEP = 1;
    let hasShownInstructions = false;

    function startScrolling() {
        if (!scrollInterval) {
            scrollInterval = setInterval(() => {
                window.scrollBy(0, scrollDirection * SCROLL_STEP);
            }, scrollSpeed);
            console.log(`✅ Auto-scroll ${scrollDirection === 1 ? 'down' : 'up'} started.`);

            if (!hasShownInstructions) {
                alert('🖱️ Auto Scroll Started!\n\nControls:\n- "S" = scroll down\n- "Shift + S" = scroll up\n- "↑ / ↓" = adjust speed');
                console.log('🖱️ Controls:\n- S = scroll down\n- Shift+S = scroll up\n- ↑ / ↓ = adjust speed');
                hasShownInstructions = true;
            }
        }
    }

    function stopScrolling() {
        if (scrollInterval) {
            clearInterval(scrollInterval);
            scrollInterval = null;
            console.log("⏹️ Auto-scroll stopped.");
        }
    }

    function toggleScrolling(direction = 1) {
        if (isScrolling && scrollDirection === direction) {
            stopScrolling();
            isScrolling = false;
        } else {
            stopScrolling();
            scrollDirection = direction;
            startScrolling();
            isScrolling = true;
        }
    }

    function restartScrolling() {
        if (isScrolling) {
            stopScrolling();
            startScrolling();
        }
    }

    document.addEventListener('keydown', (e) => {
        if (e.repeat) return;
        const key = e.key;

        if (key.toLowerCase() === 's') {
            toggleScrolling(e.shiftKey ? -1 : 1);
        }

        if (key === 'ArrowUp') {
            e.preventDefault();
            scrollSpeed = Math.max(5, scrollSpeed - 5);
            restartScrolling();
            console.log(`⚡ Faster scroll (speed: ${scrollSpeed}ms)`);
        }

        if (key === 'ArrowDown') {
            e.preventDefault();
            scrollSpeed += 5;
            restartScrolling();
            console.log(`🐢 Slower scroll (speed: ${scrollSpeed}ms)`);
        }
    });
})();