Youtube Anti-Adblock Killer

Remove the anti-adblocker popup on Youtube

当前为 2024-07-05 提交的版本,查看 最新版本

此脚本不应直接安装。它是供其他脚本使用的外部库,要使用该库请加入元指令 // @require https://update.cn-greasyfork.org/scripts/499765/1405874/Youtube%20Anti-Adblock%20Killer.js

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Youtube Anti-Adblock Killer
// @namespace    https://anda.ninja/
// @version      1.0.2
// @description  Remove the anti-adblocker popup on Youtube
// @author       Axel Andaroth
// @match        https://www.youtube.com/*
// @icon         data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAC1JREFUWEft0EERAAAAAUH6lxbDZxU4s815PffjAAECBAgQIECAAAECBAgQIDAaPwAh6O5R/QAAAABJRU5ErkJggg==
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    console.log('Youtube Anti-Adblock Killer by Axel Andaroth')
    let video = document.querySelector('video') // find the video player in page
    let overlay, closeBtn, noRenderer, playerContainerOuter = null // DOM
    const interval = setInterval(() => { // lazy repeat (^:
        const dialogs = document.querySelectorAll('tp-yt-paper-dialog') || [] // find all dialogs
        if (Array.from(dialogs).length) console.log('dialogs opened:',dialogs)
        // find the anti-adblock one, use the expression you like:
        if (!playerContainerOuter) playerContainerOuter = document.querySelector('div.player-container-outer') // find outer player
        playerContainerOuter.style.visibility = "initial" // force visible player
        if (!noRenderer) noRenderer = document.querySelector('yt-playability-error-supported-renderers') // find player warning
        noRenderer.style.display = "none" // hide player warning
        const antiAdBlockDialog = Array.from(dialogs).find((d) => (
            !!d.innerHTML.toLowerCase().includes("bloqueur de publicité")
            || !!d.innerHTML.toLowerCase().includes("autoriser youtube ads")
            || !!d.innerHTML.toLowerCase().includes("blockers are not allowed")
            || !!d.innerHTML.toLowerCase().includes("blockers violate")
            || !!d.innerHTML.toLowerCase().includes("allow youtube ads")
        )) // endof find
        if (!!antiAdBlockDialog) { // there is an anti-adblock dialog
            antiAdBlockDialog.style.display = "none" // hide the popup
            if (!overlay) overlay = document.querySelector('tp-yt-iron-overlay-backdrop') // get overlay
            else overlay.style.display = "none" // hide overlay
            if (!video) video = document.querySelector('video') // find the video player in page
            video.play() // force play
            if (!closeBtn) closeBtn = antiAdBlockDialog.querySelector('div.yt-spec-touch-feedback-shape__fill') // find close button
            else {
                closeBtn.click() // press the close button to prevent popup come back
                antiAdBlockDialog.remove()
            }
        } // endof adblock dialog
    },1000) // endof interval
})();

/* COMMUNICATION
We don't want to pay a Premium because
we will still see sponsored contents because
YT doesn't compensate their creators sufficiently
THANK YOU */