ZeroAd Engine

Bypass ads and skip interruptions in HTML5 games. Instantly auto-completes Poki SDK ads (commercialBreak/rewardedBreak), AdInPlay ads, and CrazyGames reward overlays/promo screens. Blocks iframes, video ads, intrusive containers, and adblock detection warnings. Improved future-proof AdInPlay bypass + adblock evasion (tested on taming.io, Poki, CrazyGames, Ninja.io).

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name ZeroAd Engine
// @namespace http://tampermonkey.net/
// @version 2026.02.12.1
// @description Bypass ads and skip interruptions in HTML5 games. Instantly auto-completes Poki SDK ads (commercialBreak/rewardedBreak), AdInPlay ads, and CrazyGames reward overlays/promo screens. Blocks iframes, video ads, intrusive containers, and adblock detection warnings. Improved future-proof AdInPlay bypass + adblock evasion (tested on taming.io, Poki, CrazyGames, Ninja.io).
// @author Vũ (updated with Grok)
// @match *://*/*
// @license MIT
// @grant none
// ==/UserScript==

(function () {
    'use strict';

    /////////////////////////////////////////////
    // [1] Robust Direct Function Patch for PokiSDK
    /////////////////////////////////////////////

    function patchPokiSDK() {
        if (typeof window.PokiSDK !== 'object') return false;

        const sdk = window.PokiSDK;

        if (sdk.__patched) return true;
        sdk.__patched = true;

        const instantResolve = (value = undefined) => Promise.resolve(value);

        if (typeof sdk.init === 'function') {
            sdk.init = function (...args) {
                console.log('[AdBypasser] 🚀 PokiSDK.init instantly resolved');
                return instantResolve();
            };
        }

        if (typeof sdk.commercialBreak === 'function') {
            sdk.commercialBreak = function (onStart) {
                console.log('[AdBypasser] ⏭ PokiSDK.commercialBreak skipped');
                if (typeof onStart === 'function') onStart();
                return instantResolve();
            };
        }

        if (typeof sdk.rewardedBreak === 'function') {
            sdk.rewardedBreak = function (options = {}) {
                console.log('[AdBypasser] 🎁 PokiSDK.rewardedBreak instantly rewarded');
                if (typeof options === 'function') options();
                else if (typeof options.onStart === 'function') options.onStart();
                return instantResolve(true);
            };
        }

        if (typeof sdk.displayAd === 'function') {
            sdk.displayAd = function () {
                console.log('[AdBypasser] 🚫 PokiSDK.displayAd blocked');
                return instantResolve();
            };
        }

        if (typeof sdk.destroyAd === 'function') {
            sdk.destroyAd = function () {
                console.log('[AdBypasser] 🗑️ PokiSDK.destroyAd suppressed');
            };
        }

        console.log('[AdBypasser] 🧠 PokiSDK fully patched');
        return true;
    }

    /////////////////////////////////////////////
    // [2] Enhanced AdInPlay SDK Patch (future-proof + callback/promise support)
    /////////////////////////////////////////////

    function patchAdInPlay() {
        if (typeof window.adinplay !== 'object' || window.adinplay.__patched) return;

        window.adinplay.__patched = true;
        console.log('[AdBypasser] 🔒 AdInPlay SDK neutralized (enhanced)');

        const blockedMethods = [
            'play', 'preroll', 'midroll', 'postroll', 'banner',
            'rewarded', 'reward', 'rewardVideo', 'interstitial',
            'show', 'showAd', 'display', 'displayAd', 'init'
        ];

        window.adinplay = new Proxy(window.adinplay, {
            get(target, prop) {
                if (blockedMethods.includes(prop)) {
                    return (...args) => {
                        console.log(`[AdBypasser] ⛔ AdInPlay.${String(prop)}() blocked & resolved`);
                        // Call any callbacks (common pattern)
                        args.forEach(arg => {
                            if (typeof arg === 'function') arg();
                        });
                        // Resolve with success for rewarded types
                        const isRewarded = /reward/i.test(String(prop));
                        return Promise.resolve(isRewarded ? true : undefined);
                    };
                }
                return target[prop];
            }
        });
    }

    /////////////////////////////////////////////
    // [3] DOM Ad + Adblock Warning Nuker Selectors
    /////////////////////////////////////////////

    const adSelectors = [
        '#preroll', '#adsbox',
        'iframe[src*="ads"]', 'iframe[title="Advertisement"]',
        'video[title="Advertisement"]',
        '[id^="ad_"]', '[id$="_ad"]', '[id="ad"]',
        '[class="ad"]', '[class^="ad-"]', '[class$="-ad"]',
        '[class~="ad-banner"]', '[class~="adbox"]', '[class~="adunit"]',
        '[class*="pokiSdk"]', 'div[id^="google_ads"]', 'div[id^="div-gpt"]',
        'div[class*="banner-ad"]', 'div[class*="ad-wrapper"]',
        'script[src*="ads"]',
        '.pokiSdkContainer', '.pokiSdkVideoContainer', '.pokiSDKAdContainer',
        '.pokiSdkSpinnerContainer', '.pokiSdkPauseButtonContainer', '.pokiSdkStartAdButton',
        '.ad-container', '.video-ad', '.interstitial-ad', '.rewarded-ad',
        '[class*="poki-pill"]', '.poki-pill',
        // Adblock detection/warning overlays (common patterns)
        '[class*="adblock"]', '[id*="adblock"]',
        '[class*="blocker"]', '[id*="blocker"]',
        '.adblock-warning', '.adblocker-modal', '.adblock-detected',
        '#adblock', '#disableAdblock', '.please-disable-adblock',
        '.adb-modal', '.adblocker-message', '.disable-adblock-message'
    ];

    const removedSelectors = new Set();

    function removeAdElements() {
        adSelectors.forEach(selector => {
            const elements = document.querySelectorAll(selector);
            if (elements.length > 0) {
                elements.forEach(el => el.remove());
                if (!removedSelectors.has(selector)) {
                    console.log(`[AdBypasser] 💣 Removed: ${selector}`);
                    removedSelectors.add(selector);
                }
            }
        });
    }

    function safeRemoveAdElements() {
        if ('requestIdleCallback' in window) {
            requestIdleCallback(removeAdElements, { timeout: 100 });
        } else {
            setTimeout(removeAdElements, 0);
        }
    }

    /////////////////////////////////////////////
    // [4] CrazyGames Promo Skip
    /////////////////////////////////////////////

    function handleCrazyGamesPromo() {
        const btn = document.getElementById('mainContinuePlayingButton');
        if (btn) {
            console.log('[AdBypasser] 🎯 CrazyGames promo detected — auto-clicking Continue');
            btn.click();
            let promoDiv = btn.closest('div.MuiGrid-root');
            if (promoDiv) {
                promoDiv.remove();
                console.log('[AdBypasser] 💥 CrazyGames promo container removed');
            }
        }
    }

    /////////////////////////////////////////////
    // [5] MutationObserver
    /////////////////////////////////////////////

    function startMutationWatch() {
        const observer = new MutationObserver(() => {
            patchAdInPlay();
            safeRemoveAdElements();
            handleCrazyGamesPromo();
        });

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

        console.log('[AdBypasser] 👁️ MutationObserver activated');
    }

    /////////////////////////////////////////////
    // [6] Iframe Ad Remover
    /////////////////////////////////////////////

    const iframeObserver = new MutationObserver(() => {
        document.querySelectorAll('iframe').forEach(iframe => {
            try {
                const src = iframe.src || iframe.getAttribute('src');
                if (src && /ads|doubleclick|preroll|videoads/i.test(src)) {
                    iframe.remove();
                    console.log('[AdBypasser] 🪓 Removed suspicious iframe:', src);
                }
            } catch (e) { }
        });
    });

    iframeObserver.observe(document.body || document.documentElement, {
        childList: true,
        subtree: true
    });

    /////////////////////////////////////////////
    // [7] Initialization
    /////////////////////////////////////////////

    window.addEventListener('DOMContentLoaded', () => {
        let attempts = 0;
        const maxAttempts = 20;
        const interval = setInterval(() => {
            if (patchPokiSDK() || attempts++ >= maxAttempts) {
                clearInterval(interval);
                if (attempts >= maxAttempts) {
                    console.warn('[AdBypasser] PokiSDK patch timeout');
                }
            }
        }, 800);

        patchAdInPlay();
        safeRemoveAdElements();
        handleCrazyGamesPromo();
        startMutationWatch();
    });

    const runtime = setInterval(() => {
        patchPokiSDK();
        patchAdInPlay();
        safeRemoveAdElements();
        handleCrazyGamesPromo();
    }, 1000);

    setTimeout(() => {
        clearInterval(runtime);
        console.log('[AdBypasser] 🛑 Startup interval cleared');
    }, 30000);

})();