xfree.com Adblocker

Blocks simply every ad on xfree.com

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         xfree.com Adblocker
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Blocks simply every ad on xfree.com
// @author       jj251
// @match        https://*.xfree.com/*
// @grant        none
// @run-at       document-start
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    // Erweiterte Liste für den Netzwerk-Blocker
    const blacklistedKeywords = [
        'r51.com',
        'horrorporn.com',
        'czechmassage.com',
        'recomb_id=banner',
        '/xfpro',
        'prbn',
        'hqmediago.com',
        'lifepornstories.com',
        'czechcasting.com'
    ];

    // Funktion zur Überprüfung, ob eine URL Werbung ist
    function isAdUrl(url) {
        if (!url) return false;
        const urlString = String(url).toLowerCase();
        return blacklistedKeywords.some(keyword => urlString.includes(keyword.toLowerCase()));
    }

    // 1. FETCH API BLOCKER
    if (window.fetch) {
        const originalFetch = window.fetch;
        window.fetch = function(input, init) {
            const url = (typeof input === 'string') ? input : (input && input.url);

            if (isAdUrl(url)) {
                console.log('%c[Ad-Blocker] Fetch blockiert:', 'color: red;', url);
                return Promise.resolve(new Response(JSON.stringify({}), { status: 200 }));
            }
            return originalFetch.apply(this, arguments);
        };
    }

    // 2. XHR (XMLHttpRequest) BLOCKER
    const originalOpen = XMLHttpRequest.prototype.open;
    XMLHttpRequest.prototype.open = function(method, url, async, user, password) {
        if (isAdUrl(url)) {
            console.log('%c[Ad-Blocker] XHR blockiert:', 'color: red;', url);
            this.send = function() { };
            return;
        }
        return originalOpen.apply(this, arguments);
    };

    // 3. TIMER BYPASS (Für die 5-Sekunden-Sperren)
    const originalTimeout = window.setTimeout;
    window.setTimeout = function(callback, delay, ...args) {
        if (delay >= 2000 && delay <= 6000) {
            return originalTimeout(callback, 0, ...args);
        }
        return originalTimeout(callback, delay, ...args);
    };

    // 4. HTML-ENTFERNUNG (Für die Seitenelemente)
    function removeSidebarAndHtmlAds() {
        // Sucht nach den neuen Werbe-Klassen aus deinem HTML
        const adElements = document.querySelectorAll('.prbn__media, .czavbanner, .prbn');

        adElements.forEach(el => {
            // Wir prüfen, ob im Element (oder Video-Src) eine der Blacklist-Webseiten steckt
            const htmlString = el.innerHTML || '';
            const videoSrc = el.src || '';

            const isTargetAd = blacklistedKeywords.some(keyword =>
                htmlString.includes(keyword) || videoSrc.includes(keyword)
            );

            // Wenn es ein Treffer ist oder die Klasse exakt matcht, komplett zerstören
            if (isTargetAd || el.classList.contains('czavbanner')) {
                // Wir löschen das Element komplett, damit die Seite sauber aussieht
                el.remove();
            }
        });
    }

    // Läuft alle 100ms, um neu reingeladene Seitenbanner sofort wegzubrennen
    setInterval(removeSidebarAndHtmlAds, 100);

    // Zusätzlicher CSS-Injektor, um das Anzeigen im Keim zu ersticken
    const style = document.createElement('style');
    style.innerHTML = `
        .czavbanner, .prbn__media, [class*="prbn"] {
            display: none !important;
            visibility: hidden !important;
            opacity: 0 !important;
            pointer-events: none !important;
        }
    `;
    document.documentElement.appendChild(style);

})();