Greasy Fork 还支持 简体中文。

Youtube - Advertisement Hide

Выключает рекламу или звук в рекламе на ресурсе Youtube

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name           Youtube - Advertisement Hide
// @namespace      scriptomatika
// @author         mouse-karaganda
// @description    Выключает рекламу или звук в рекламе на ресурсе Youtube
// @license        MIT
// @include        https://*.youtube.com/*
// @require        https://greasyfork.org/scripts/379902-include-tools/code/Include%20Tools.js
// @icon           https://www.google.com/s2/favicons?sz=64&domain=www.youtube.com
// @version        1.5
// @grant          none
// ==/UserScript==

(function() {
    let console = window.console;
    let $ = window.jQuery;
    let $$ = window.__krokodil;

    $$.renderStyle(
        '',
        ''
    );

    window.greasyMovieVolumeOn = false;

    /**
     * Выключает звук на внутренней рекламе
     */
    let muteInternalAdverts = function() {
        let button;

        if (button = $$.get(`.ytp-ad-overlay-slot .ytp-ad-overlay-close-button`)) {
            $$.fireEvent(button, 'click');
        }
        if (button = $$.get(`.video-ads .ytp-ad-skip-button-container`)) {
            $$.fireEvent(button, 'click');
        }
        // Сравнивать по строковому значению title - ужасно.
        // Но другого способа нет, потому что не меняются другие атрибуты
        if (button = $$.get(`.ytp-ad-preview-container`)) {
            if (button = $$.get(`#movie_player .ytp-mute-button[title^="Отключение звука"]`)) {
                $$.fireEvent(button, 'click');
            }
            window.greasyMovieVolumeOn = false;
        } else {
            if (!window.greasyMovieVolumeOn) {
                if (button = $$.get(`#movie_player .ytp-mute-button[title^="Включить звук"]`)) {
                    $$.fireEvent(button, 'click');
                }
                window.greasyMovieVolumeOn = true;
            }
        }
    };

    if (false) {
        let muteTimer = setInterval(muteInternalAdverts, 80);
    }

    (function() {
        let nowOpenedAdvert = false;

        let gete = (param) => document.querySelector(param);

        let skipper = () => {
            let vide = gete('#movie_player video');
            if (vide) {
                let info = {
                    duration: vide.duration,
                    buffered: vide.buffered
                };
                console.log('ytscript :: skipper movie_player = ', info);
                //vide.play();
                vide.currentTime += 3600;
            }
        };
        //skipper();

        let advertCatcher = () => {
            let advertTitle = gete('.ytp-ad-player-overlay-layout div[aria-label="Реклама"]');
            //nowOpenedAdvert = !!advertTitle;
            if (advertTitle) {
                 console.log('ytscript :: advertTitle = ', advertTitle);
                 skipper();
            }
        };

        setInterval(advertCatcher, 50);
        return;

        let holder = () => {
            let btnSkip = document.querySelector('.video-ads button[id^="skip-button"]');
            if (btnSkip) {
                btnSkip.click();
            }
        };
        setTimeout(holder, 100);
    })();

    console.log('Youtube - Advertisement Hide 💬 1.5');
})();