YouTube - Disable Autoplay & Animations

Disable Autoplay & Animations

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴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);
})();