AdBlockThisYT2

Permite reproducir videos con AdBlock activado sin errores ni bloqueos, incluso en nueva pestaña. Corrige pausa automática.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         AdBlockThisYT2
// @namespace    SebaARG22
// @version      3.0.2
// @description  Permite reproducir videos con AdBlock activado sin errores ni bloqueos, incluso en nueva pestaña. Corrige pausa automática.
// @author       SebaARG22
// @match        *://www.youtube.com/*
// @icon         https://i.imgur.com/fd1D46S.png
// @run-at       document-start
// @license      MIT
// @grant        none
// ==/UserScript==

(function () {
    'use strict';

    const LOG_PREFIX = '[😭 CryTubeFix]';

    console.log(`${LOG_PREFIX} Script iniciado. Bloqueando el berrinche de YouTube.`);

    // 1. Oculta overlays molestos
    const css = `
        ytd-enforcement-message-view-model,
        tp-yt-paper-dialog,
        ytd-popup-container,
        #dialog,
        .ytp-ad-overlay-container,
        .ytp-ad-player-overlay,
        .ytp-ad-module {
            display: none !important;
            opacity: 0 !important;
            visibility: hidden !important;
        }
        body {
            overflow: auto !important;
        }
    `;
    const style = document.createElement('style');
    style.textContent = css;
    document.documentElement.appendChild(style);

    console.log(`${LOG_PREFIX} CSS inyectado. Publicidad visual: OUT.`);

    // 2. Observa cambios en el DOM para eliminar bloqueos dinámicos
    const observer = new MutationObserver(() => {
        const dialogs = document.querySelectorAll('ytd-popup-container tp-yt-paper-dialog, ytd-enforcement-message-view-model');
        dialogs.forEach(el => {
            console.log(`${LOG_PREFIX} Eliminado un popup llorón.`);
            el.remove();
        });
        const backdrop = document.querySelector('#backdrop');
        if (backdrop) {
            console.log(`${LOG_PREFIX} Backdrop eliminado.`);
            backdrop.remove();
        }
        document.body.style.overflow = 'auto';
    });
    observer.observe(document, { childList: true, subtree: true });

    console.log(`${LOG_PREFIX} Observador activado. Listo para limpiar rabietas.`);

    // 3. Soluciona pausa automática del video
    if (window.location.pathname.startsWith('/watch')) {
        window.addEventListener('DOMContentLoaded', () => {
            const tryPlay = () => {
                const player = document.querySelector('video');
                if (player) {
                    console.log(`${LOG_PREFIX} Intentando reproducir el video automáticamente...`);
                    const playPromise = player.play();
                    if (playPromise !== undefined) {
                        playPromise.catch((err) => {
                            console.warn(`${LOG_PREFIX} Error al intentar reproducir:`, err);
                        });
                    }
                } else {
                    console.warn(`${LOG_PREFIX} Player no encontrado. Reintentando en 500ms...`);
                    setTimeout(tryPlay, 500);
                }
            };
            tryPlay();
        });
    }

})();