Auto Scroll for YouTube shorts + extra features

Auto Scroll, Also ignores SponsorBlock videos, right click gives immunity to move mouse. thumbs down auto scrolls to next video

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         Auto Scroll for YouTube shorts + extra features
// @namespace    http://tampermonkey.net/
// @version      5.0
// @description  Auto Scroll, Also ignores SponsorBlock videos, right click gives immunity to move mouse. thumbs down auto scrolls to next video
// @author       Justn
// @match        https://www.youtube.com/shorts/*
// @grant        none
// @run-at       document-end
// @license      MIT
// ==/UserScript==

(function () {
    'use strict';

    const STORAGE_KEY = 'shortsAutoScrollMode';
    let mode = localStorage.getItem(STORAGE_KEY) || 'basic';

    let isEnabled = true;
    let mouseMoved = false;
    let leftClickHeld = false;
    let rightClickHeld = false;
    let lastX = null;
    let lastY = null;
    const MIN_MOVE = 100;

    const toggle = document.createElement('div');
    toggle.style.cssText = 'position:fixed;bottom:20px;right:20px;padding:0 18px;height:60px;border-radius:30px;background:#ff0000;color:white;font:bold 18px Arial;display:flex;align-items:center;justify-content:center;cursor:pointer;z-index:9999999;box-shadow:0 0 20px black;user-select:none;transition:all 0.3s;min-width:100px;';
    toggle.textContent = 'AUTO';
    toggle.title = 'Click to toggle auto-scroll';
    document.body.appendChild(toggle);

    const updateToggle = () => {
        if (!isEnabled) {
            toggle.style.background = '#666';
            toggle.textContent = 'OFF';
            toggle.style.color = 'white';
            toggle.style.textShadow = 'none';
        } else {
            toggle.style.background = '#ff0000';
            toggle.textContent = mouseMoved ? 'MANUAL' : 'AUTO';
            toggle.style.color = mouseMoved ? '#000000' : 'white';
            toggle.style.textShadow = mouseMoved ? '0 0 10px white' : 'none';
        }
    };

    const createPopup = () => {
        const popup = document.createElement('div');
        popup.style.cssText = 'position:fixed;bottom:90px;right:20px;width:180px;background:#333;color:white;border-radius:10px;padding:10px;box-shadow:0 0 20px black;z-index:1000000;display:none;flex-direction:column;';
        const options = ['Basic Mode', 'Advanced Mode', 'Instructions'];
        options.forEach(text => {
            const item = document.createElement('div');
            item.textContent = text;
            item.style.cssText = 'padding:10px;cursor:pointer;';
            item.onmouseover = () => item.style.background = '#555';
            item.onmouseout = () => item.style.background = 'transparent';
            item.onclick = () => {
                if (text === 'Basic Mode') {
                    mode = 'basic';
                } else if (text === 'Advanced Mode') {
                    mode = 'advanced';
                } else if (text === 'Instructions') {
                    alert(`YouTube Auto Scroll - Instructions

BASIC MODE (default):
- Pill says "AUTO" (auto-scroll active)
- Click pill → "OFF" (auto-scroll inactive)
- Click again → back to "AUTO"

Advanced mode:
- Pill Cycles "AUTO" → "MANUAL" → "OFF"
- Hold left or right mouse button → move mouse freely without triggering MANUAL mode
- Click dislike button on video → instant skip to next Short
- MANUAL indicator activated upon significant mouse movement`);
                }
                localStorage.setItem(STORAGE_KEY, mode);
                popup.style.display = 'none';
                mouseMoved = false;
                isEnabled = true;
                updateToggle();
            };
            popup.appendChild(item);
        });
        document.body.appendChild(popup);
        return popup;
    };

    const popup = createPopup();

    toggle.onclick = () => {
        if (mode === 'basic') {
            isEnabled = !isEnabled;
        } else {
            if (isEnabled) {
                if (mouseMoved) {
                    isEnabled = false;
                } else {
                    mouseMoved = true;
                }
            } else {
                isEnabled = true;
                mouseMoved = false;
            }
        }
        updateToggle();
    };

    toggle.oncontextmenu = e => {
        e.preventDefault();
        popup.style.display = popup.style.display === 'flex' ? 'none' : 'flex';
    };

    const smashNext = () => {
        const btn = document.querySelector('button[aria-label="Next (shortcut: ↓)"]') || document.querySelector('button[aria-label*="Next"]');
        if (btn) btn.click();
    };

    document.addEventListener('mousedown', e => {
        if (mode === 'advanced') {
            if (e.button === 0) leftClickHeld = true;
            if (e.button === 2) rightClickHeld = true;
        }
        if (lastX === null) {
            lastX = e.clientX;
            lastY = e.clientY;
        }
    });

    document.addEventListener('mouseup', e => {
        if (mode === 'advanced') {
            if (e.button === 0) leftClickHeld = false;
            if (e.button === 2) rightClickHeld = false;
        }
    });

    document.addEventListener('mousemove', e => {
        if (mode !== 'advanced') return;
        if (leftClickHeld || rightClickHeld) {
            lastX = e.clientX;
            lastY = e.clientY;
            return;
        }

        if (lastX === null) {
            lastX = e.clientX;
            lastY = e.clientY;
            return;
        }

        const dx = Math.abs(e.clientX - lastX);
        const dy = Math.abs(e.clientY - lastY);
        if (dx >= MIN_MOVE || dy >= MIN_MOVE) {
            mouseMoved = true;
            updateToggle();
            lastX = e.clientX;
            lastY = e.clientY;
        }
    });

    document.addEventListener('click', e => {
        if (!isEnabled || mode !== 'advanced') return;
        const target = e.target.closest('button');
        if (target && target.getAttribute('aria-label') && target.getAttribute('aria-label').toLowerCase().includes('dislike')) {
            setTimeout(smashNext, 150);
        }
    });

    window.addEventListener('yt-navigate-start', () => {
        if (!location.pathname.startsWith('/shorts/')) {
            toggle.style.display = 'none';
        }
    });

    window.addEventListener('yt-navigate-finish', () => {
        if (location.pathname.startsWith('/shorts/')) {
            toggle.style.display = 'flex';
            updateToggle();
        }
    });

    setInterval(() => {
        if (!isEnabled) return;
        if (document.querySelector('.ytp-sponsor-skip-button, .sbSkipButton, [data-sb-segment]')) {
            smashNext();
            return;
        }
        const video = document.querySelector('ytd-reel-video-renderer[is-active] video');
        if (!video || isNaN(video.duration)) return;
        if (video.currentTime < 0.5) {
            if (mode === 'advanced') {
                if (!leftClickHeld && !rightClickHeld) mouseMoved = false;
            }
            updateToggle();
        }
        if (video.currentTime >= video.duration - 0.2) {
            if (mode === 'advanced' && mouseMoved) return;
            smashNext();
        }
    }, 100);
})();