☰

MissAV Ad Cleaner

Remove MissAV advertisements, iframes and popup ads.

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==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);

})();