YouTube Anti-AdBlock Bypass via YouTube Enhancer

A simple method of bypassing YouTube's AdBlock Detection using YouTube Enhancer's "Remove Ads" button. Does not require the use of any external website like similar tools do :)

目前為 2023-10-21 提交的版本,檢視 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         YouTube Anti-AdBlock Bypass via YouTube Enhancer
// @namespace    https://e-z.bio/yaw
// @version      1.2
// @description  A simple method of bypassing YouTube's AdBlock Detection using YouTube Enhancer's "Remove Ads" button. Does not require the use of any external website like similar tools do :)
// @author       Yaw
// @match        https://www.youtube.com/*
// @run-at       document-start
// @license      MIT
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    var searchInterval = 800
    var failCounter = 0
    var toggleSwitch = true

    function checkForButton() {
        const currentURL = window.location.href;
        if (toggleSwitch) {
            if (/https:\/\/www\.youtube\.com\/watch\?.*/.test(currentURL)) { // match url pattern - credits: Zion
                const button = document.getElementById("efyt-not-interested");
                const adShowing = [...document.querySelectorAll('.ad-showing')][0];
                if (adShowing) {
                    if (button) {
                        button.click();
                        console.log("Button found and clicked.")
                        failCounter = 0
                    }
                    else {
                        console.log("Failed to find button. Retrying in ", searchInterval, " ms")
                        failCounter = failCounter + 1
                    }
                    if (failCounter > 10) {
                        var uresponse = window.confirm("Failed to find the button more than 10 times. Please make sure that YouTube Enhancer is installed.\n\nPressing 'OK' will take you to the installation page.\nPressing 'Cancel' will disable the Bypasser for this session.");
                        if (uresponse) {
                            window.open("https://chrome.google.com/webstore/detail/enhancer-for-youtube/ponfpcnoihfmfllpaingbgckeeldkhle");
                            failCounter = 0
                        } else {
                            toggleSwitch = false
                        }
                    }
                }
            }
        }
    }

    setInterval(checkForButton, searchInterval);
})();