Enhanced youtube

Automatically skips YouTube ads, mutes them, disables autoplay, removes end screens, expands descriptions, and hides Up Next.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Enhanced youtube
// @namespace    Index
// @version      1.0
// @description  Automatically skips YouTube ads, mutes them, disables autoplay, removes end screens, expands descriptions, and hides Up Next.
// @author       Joel
// @match        *://www.youtube.com/*
// @license      MIT
// @grant        none
// ==/UserScript==

(function () {
    'use strict';

    function skipAd() {
        const skipButton = document.querySelector('.ytp-ad-skip-button');
        if (skipButton) {
            skipButton.click();
            console.log('Skipped an ad.');
        }
    }

    function muteAd() {
        const isAdPlaying = document.querySelector('.ad-showing');
        const video = document.querySelector('video');
        if (isAdPlaying && video && !video.muted) {
            video.muted = true;
            console.log('Muted video during ad.');
        } else if (!isAdPlaying && video && video.muted) {
            video.muted = false;
            console.log('Unmuted video after ad.');
        }
    }

    function removeEndScreens() {
        const elements = document.querySelectorAll('.ytp-ce-element');
        elements.forEach(el => el.remove());
    }

    function disableAutoplayToggle() {
        const autoplayButton = document.querySelector('.ytp-autonav-toggle-button[aria-checked="true"]');
        if (autoplayButton) {
            autoplayButton.click();
            console.log('Autoplay disabled.');
        }
    }

    function expandDescription() {
        const moreButton = document.querySelector('#expand .more-button');
        if (moreButton) {
            moreButton.click();
            console.log('Expanded description.');
        }
    }

    function hideUpNextSection() {
        const upNext = document.getElementById('related');
        if (upNext) {
            upNext.style.display = 'none';
            console.log('Hiding Up Next section.');
        }
    }

    function applyEnhancements() {
        skipAd();
        muteAd();
        removeEndScreens();
        disableAutoplayToggle();
        expandDescription();
        hideUpNextSection();
    }

    setInterval(applyEnhancements, 1000);
})();