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

目前為 2025-12-03 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==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);
})();