YouTube - Disable Autoplay & Animations

Disable Autoplay & Animations

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         YouTube - Disable Autoplay & Animations
// @match        https://www.youtube.com/watch*
// @grant        GM_addStyle
// @version 1
// @namespace YouTube Disable Autoplay Animations
// @license MIT 
// @description Disable Autoplay & Animations
// ==/UserScript==

(function() {
    'use strict';

    // Отключаем большинство анимаций перехода и трансформации
    GM_addStyle(`
        * {
           transition: none !important;
           animation: none !important;
        }
    `);

    // Функция для отключения кнопки автовоспроизведения
    function disableAutoplay() {
        const autoplayButton = document.querySelector('.ytp-autonav-toggle-button');
        // Проверяем, включена ли она (атрибут aria-checked="true")
        if (autoplayButton && autoplayButton.getAttribute('aria-checked') === 'true') {
            autoplayButton.click();
            console.log('[Userscript] Автовоспроизведение отключено.');
        }
    }

    // Запускаем с интервалом, так как плеер может загружаться не сразу
    const interval = setInterval(() => {
        if (document.querySelector('.ytp-autonav-toggle-button')) {
            disableAutoplay();
            clearInterval(interval);
        }
    }, 500);
})();