☰

BoyfriendTV Mobile Cleaner

Removes ad blocks, promo widgets, and forces videos to open in the current tab without popups.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name         BoyfriendTV Mobile Cleaner
// @namespace    http://tampermonkey.net/
// @version      1.1
// @description  Removes ad blocks, promo widgets, and forces videos to open in the current tab without popups.
// @match        *://*.boyfriendtv.com/*
// @grant        none
// @run-at       document-start
// ==/UserScript==

(function() {
    'use strict';

    // Function to remove all identified ad elements
    const removeAds = () => {
        // A list of CSS selectors targeting the various ad types
        const adSelectors = [
            '.content-block.no-popup', // Original homepage ad blocks
            '#wgt-360',                // Specific ID for the FapHouse video widget
            '.wgt-container',          // Class for video widget containers
            'a.fh-line',               // The "GET ACCESS" text banner link
            '.info-wrap',              // The wrapper for sponsored text links and iframes
            '.zn-label'                // The tiny "Ad" indicator spans
        ];

        adSelectors.forEach(selector => {
            document.querySelectorAll(selector).forEach(ad => {
                // If the ad is the text banner link, remove its parent container to keep the DOM clean
                if (ad.classList.contains('fh-line') && ad.parentElement && ad.parentElement.tagName === 'DIV') {
                    ad.parentElement.remove();
                } else {
                    ad.remove();
                }
            });
        });
    };

    // Function to fix link behavior and prevent popups
    const fixLinks = () => {
        // 1. Remove the trigger class from the wrapper
        document.querySelectorAll('.js-pop').forEach(el => {
            el.classList.remove('js-pop');
        });

        // 2. Target the actual video links
        const videoLinks = document.querySelectorAll('a[href^="/videos/"]');
        videoLinks.forEach(link => {
            // Remove target="_blank" just in case the site injects it
            link.removeAttribute('target');

            // Intercept the click to guarantee standard navigation
            link.addEventListener('click', function(e) {
                e.preventDefault();
                e.stopPropagation(); // Stop the site's scripts from seeing this click
                window.location.href = this.href;
            }, true); // 'true' uses the capture phase, firing before other scripts
        });

        // Disable the global popunder variables defined in their inline scripts
        if (typeof window.popunder !== 'undefined') {
            window.popunder = null;
        }
        if (typeof window.videoPopunder !== 'undefined') {
            window.videoPopunder = null;
        }
    };

    // Main execution function
    const runCleanup = () => {
        removeAds();
        fixLinks();
    };

    // Run when the DOM is fully loaded
    window.addEventListener('DOMContentLoaded', runCleanup);

    // Set up a MutationObserver to catch elements loaded dynamically (like infinite scroll or delayed ad injections)
    const observer = new MutationObserver((mutations) => {
        let shouldRun = false;
        for (const mutation of mutations) {
            if (mutation.addedNodes.length > 0) {
                shouldRun = true;
                break;
            }
        }
        if (shouldRun) {
            runCleanup();
        }
    });

    // Start observing the body for injected nodes as soon as it exists
    const startObserver = setInterval(() => {
        if (document.body) {
            observer.observe(document.body, { childList: true, subtree: true });
            clearInterval(startObserver);
        }
    }, 50);

})();