AdBlockThisYT2

Evita bloqueos por AdBlock sin romper botones ni dejar fondo oscuro que bloquea clicks. Intenta autoplay sin mute ni botones, y elimina capa .opened./Avoids AdBlock restrictions without breaking buttons or leaving a dark overlay that blocks clicks. Attempts autoplay without mute or buttons, and removes the .opened layer.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name         AdBlockThisYT2
// @namespace    SebaARG22
// @version      3.1.8
// @description  Evita bloqueos por AdBlock sin romper botones ni dejar fondo oscuro que bloquea clicks. Intenta autoplay sin mute ni botones, y elimina capa .opened./Avoids AdBlock restrictions without breaking buttons or leaving a dark overlay that blocks clicks. Attempts autoplay without mute or buttons, and removes the .opened layer.
// @author       SebaARG22
// @match        *://www.youtube.com/*
// @icon         https://i.imgur.com/fd1D46S.png
// @run-at       document-start
// @grant        none
// @license      MIT
// ==/UserScript==

(function () {
    'use strict';

    const LOG_PREFIX = '[😭 CryTubeFix]';

    console.log(`${LOG_PREFIX} Script iniciado.`);

    // CSS para ocultar anuncios y capa .opened
    const css = `
        .ytp-ad-overlay-container,
        .ytp-ad-player-overlay,
        .ytp-ad-module,
        ytd-enforcement-message-view-model[data-adblock-hidden] {
            display: none !important;
        }

        .opened,
        .opened * {
            background: transparent !important;
            pointer-events: none !important;
            user-select: none !important;
            opacity: 0 !important;
            z-index: 0 !important;
        }
    `;
    const style = document.createElement('style');
    style.textContent = css;
    document.documentElement.appendChild(style);

    function removeOpenedOverlay() {
        const openedElements = document.querySelectorAll('.opened');
        openedElements.forEach(el => {
            if (el.parentElement) el.parentElement.style.pointerEvents = 'auto';
            el.remove();
            console.log(`${LOG_PREFIX} Eliminado elemento .opened.`);
        });
    }

    const observer = new MutationObserver(() => {
        const messages = document.querySelectorAll('ytd-enforcement-message-view-model');
        messages.forEach(el => {
            const text = el.innerText?.toLowerCase() || '';
            if (text.includes('ad blocker') || text.includes('bloqueador de anuncios')) {
                el.setAttribute('data-adblock-hidden', 'true');
                document.body.style.overflow = 'auto';
                console.log(`${LOG_PREFIX} Ocultado aviso AdBlock.`);
            }
        });
        removeOpenedOverlay();
    });
    observer.observe(document, { childList: true, subtree: true });
    setInterval(removeOpenedOverlay, 500);

    function autoplayVideo() {
        const video = document.querySelector('video');
        if (!video) {
            setTimeout(autoplayVideo, 500);
            return;
        }

        video.muted = false; // No mute
        video.play().then(() => {
            console.log(`${LOG_PREFIX} Autoplay sin mute iniciado.`);
        }).catch(() => {
            console.warn(`${LOG_PREFIX} Autoplay sin mute fue bloqueado por el navegador.`);
        });
    }

    function setupAutoplayOnPage() {
        autoplayVideo();

        let lastPath = location.pathname;
        setInterval(() => {
            if (location.pathname !== lastPath) {
                lastPath = location.pathname;
                console.log(`${LOG_PREFIX} Cambio de página detectado, intentando autoplay.`);
                autoplayVideo();
            }
        }, 1000);
    }

    if (window.location.pathname.startsWith('/watch')) {
        window.addEventListener('DOMContentLoaded', setupAutoplayOnPage);
    }

})();