☰

MissAV Ad Cleaner

Remove MissAV advertisements, iframes and popup ads.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name         MissAV Ad Cleaner
// @namespace    http://tampermonkey.net/
// @version      1.1
// @author       ChatGPT
// @license      MIT
// @description  Remove MissAV advertisements, iframes and popup ads.
// @include      /^https?:\/\/missav[^/]*\//
// @run-at       document-start
// @grant        none
// ==/UserScript==

(function () {
    'use strict';

    const selector = 'iframe, #html-ads, #inpage, #SCSpotScript';

    // Block popup advertisements.
    const open = window.open;
    window.open = function (url, ...args) {
        try {
            const u = new URL(url, location.href);
            if (u.origin === location.origin &&
                u.pathname === '/pop' &&
                u.searchParams.has('url')) return null;
        } catch {}
        return open.call(this, url, ...args);
    };

    // Hide ad elements immediately.
    const style = document.createElement('style');
    style.textContent = `${selector} {
        display: none !important;
        visibility: hidden !important;
    }`;

    const clean = node => {
        if (node.nodeType !== 1 && node !== document) return;

        if (node.nodeType === 1 && node.matches(selector)) {
            node.remove();
            return;
        }

        node.querySelectorAll?.(selector).forEach(el => el.remove());
    };

    // Watch dynamically inserted elements.
    new MutationObserver(records => {
        if (document.documentElement && !style.isConnected) {
            document.documentElement.appendChild(style);
        }

        for (const record of records) {
            record.addedNodes.forEach(clean);
        }
    }).observe(document, {
        childList: true,
        subtree: true
    });

    // Initial cleanup.
    if (document.documentElement) {
        document.documentElement.appendChild(style);
    }
    clean(document);

})();