🎉 欢迎访问GreasyFork.Org 镜像站!本镜像站由公众号【爱吃馍】搭建,用于分享脚本。联系邮箱📮

Greasy fork 爱吃馍镜像

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

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

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

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

🚀 安装遇到问题?关注公众号获取帮助

公众号二维码

扫码关注【爱吃馍】

回复【脚本】获取最新教程和防失联地址

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.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

🚀 安装遇到问题?关注公众号获取帮助

公众号二维码

扫码关注【爱吃馍】

回复【脚本】获取最新教程和防失联地址

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