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.

(Tôi đã có Trình quản lý tập lệnh người dùng, hãy cài đặt nó!)

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 4.4
// @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';

    let mouseMoved = false;
    let isEnabled = true;
    let rightClickHeld = false;
    let lastX = 0;
    let lastY = 0;
    const MIN_MOVE = 25;

    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';
        }
    };
    updateToggle();

    toggle.onclick = () => {
        isEnabled = !isEnabled;
        mouseMoved = false;
        updateToggle();
    };

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

    const resetMouse = () => {
        if (!rightClickHeld) {
            mouseMoved = false;
            updateToggle();
        }
    };

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

    document.addEventListener('mouseup', e => {
        if (e.button === 2) {
            rightClickHeld = false;
            lastX = e.clientX;
            lastY = e.clientY;
        }
    });

    document.addEventListener('contextmenu', e => e.preventDefault());

    document.addEventListener('mousemove', e => {
        if (!isEnabled || rightClickHeld) 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;
        }
    });

    // FIXED: Only trigger instant skip when clicking the MAIN video dislike button
    document.addEventListener('click', e => {
        if (!isEnabled) return;

        const btn = e.target.closest('button');
        if (!btn) return;

        const aria = btn.getAttribute('aria-label') || '';
        if (aria.toLowerCase().includes('dislike this video') ||
            aria.toLowerCase().includes('dislike') && btn.closest('ytd-reel-video-renderer')) {
            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) resetMouse();
        if (video.currentTime >= video.duration - 0.2 && !mouseMoved) smashNext();
    }, 100);
})();