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-11-20 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Auto Scroll for YouTube shorts + extra features
// @namespace    http://tampermonkey.net/
// @version      4.2
// @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 = 12;

    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;
        }
    });

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

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