Greasy Fork

Universal AdBlock Bypass (Beta)

Attempts to bypass ad-blocker detection on all websites

// ==UserScript==
// @name         Universal AdBlock Bypass (Beta)
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Attempts to bypass ad-blocker detection on all websites
// @author       Snow2122
// @license      MIT
// @match        *://*/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Match all websites
    // @match        *://*/*

    // Override common ad-blocker detection variables and functions
    window.ai_adb_active = true;
    window.ai_adb_action = 0;
    window.ai_adb_undetected = function() {
        document.querySelector('body')?.setAttribute('data-data-mask', 'clear');
        if (typeof window.ai_adb_undetected_actions === 'function') {
            window.ai_adb_undetected_actions(0);
        }
    };

    // Simulate successful ad script loading
    const originalFetch = window.fetch;
    window.fetch = function(url, options) {
        if (url.includes('pagead') || url.includes('ads.') || url.includes('doubleclick')) {
            return Promise.resolve(new Response('OK', { status: 200 }));
        }
        return originalFetch.apply(this, arguments);
    };

    // Remove ad-blocker overlays and messages
    function removeAdBlockElements() {
        const overlays = document.querySelectorAll('ins > div, .ad-block-message, #adblock-overlay, .ai-adb-overlay');
        const messages = document.querySelectorAll('section > div, .adblock-notice, .ai-adb-message-window');
        overlays.forEach(el => el.remove());
        messages.forEach(el => el.remove());
    }

    // Clear ad-blocker related cookies
    function clearCookies() {
        const cookies = ['aiADB', 'aiADB_PV', 'aiADB_PR', 'adblock_detected'];
        cookies.forEach(cookie => {
            document.cookie = `${cookie}=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;`;
        });
    }

    // Ensure content visibility
    function restoreContent() {
        document.querySelectorAll('.ai-adb-hide, .adblock-hidden').forEach(el => {
            el.style.display = 'block';
            el.style.visibility = 'visible';
            el.classList.remove('ai-adb-hide', 'adblock-hidden');
        });
        document.querySelectorAll('.ai-adb-show, .adblock-show').forEach(el => {
            el.style.display = 'none';
            el.classList.remove('ai-adb-show', 'adblock-show');
        });
    }

    // Initialize bypass
    function init() {
        clearCookies();
        removeAdBlockElements();
        restoreContent();
        if (typeof window.ai_adb_undetected === 'function') {
            window.ai_adb_undetected(0);
        }
    }

    // Run when DOM is loaded
    if (document.readyState === 'loading') {
        document.addEventListener('DOMContentLoaded', init);
    } else {
        init();
    }

    // Observe for dynamically added elements
    const observer = new MutationObserver((mutations) => {
        mutations.forEach(() => {
            removeAdBlockElements();
            restoreContent();
        });
    });

    observer.observe(document.body, { childList: true, subtree: true });
})();