☰

BoyfriendTV Mobile Cleaner

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

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

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

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği indirebilmeniz için ayrıca Tampermonkey gibi bir eklenti kurmanız gerekmektedir.

Bu betiği yüklemek için bir betik yöneticisi eklentisi yüklemeniz gerekecektir.

(Zaten bir betik yöneticim var, hadi yükleyelim!)

Bu stili yüklemek için Stylus gibi bir uzantı yüklemeniz gerekir.

Bu stili yüklemek için Stylus gibi bir uzantı kurmanız gerekir.

Bu stili yükleyebilmek için Stylus gibi bir uzantı yüklemeniz gerekir.

Bu stili yüklemek için bir kullanıcı stili yöneticisi uzantısı yüklemeniz gerekir.

Bu stili yüklemek için bir kullanıcı stili yöneticisi uzantısı kurmanız gerekir.

Bu stili yükleyebilmek için bir kullanıcı stili yöneticisi uzantısı yüklemeniz gerekir.

(Zateb bir user-style yöneticim var, yükleyeyim!)

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

})();