Multi Tab Visibility

allowing to open many tabs without browser's knowing

// ==UserScript==
// @name         Multi Tab Visibility
// @copyright    Ojo Ngono
// @namespace    violentmonkey/tampermonkey script 
// @version      1.2.8.4
// @description  allowing to open many tabs without browser's knowing 
// @author       Ojo Ngono
// @include      *://*/*
// @grant        none
// @@license     Copyright OjoNgono
// ==/UserScript==

(function() {
    'use strict';
 
    // Cek apakah skrip dijalankan di dalam iframe
    if (window.top !== window.self) {
        return; // Jika dijalankan di dalam iframe, hentikan skrip
    }

    console.log('Script is running on top window.');

    const eventsToBlock = [
        "visibilitychange",
        "webkitvisibilitychange",
        "mozvisibilitychange",
        "blur",
        "focus",
        "mouseleave"
    ];

    eventsToBlock.forEach(event_name => {
        document.addEventListener(event_name, function(event) {
            console.log(`Blocking event: ${event_name}`);
            event.preventDefault();
            event.stopPropagation();
            event.stopImmediatePropagation();
        }, { capture: true, passive: false });
    });

    console.log('Attempting to override visibility and focus properties.');

    // Function to safely define properties if configurable
    const defineSafeProperty = (obj, prop, descriptor) => {
        const propertyDescriptor = Object.getOwnPropertyDescriptor(obj, prop);
        if (!propertyDescriptor || propertyDescriptor.configurable) {
            Object.defineProperty(obj, prop, descriptor);
        } else {
            console.warn(`Property "${prop}" is non-configurable and cannot be redefined.`);
        }
    };

    defineSafeProperty(document, "hasFocus", { value: () => true });
    defineSafeProperty(document, "onvisibilitychange", { value: null, writable: true });
    defineSafeProperty(document, "visibilityState", { value: "visible", writable: false });
    defineSafeProperty(document, "hidden", { value: false, writable: false });
    defineSafeProperty(document, "mozHidden", { value: false, writable: false });
    defineSafeProperty(document, "webkitHidden", { value: false, writable: false });
    defineSafeProperty(document, "webkitVisibilityState", { value: "visible", writable: false });

    console.log('Properties override complete.');

    var adblockDetected = false;

    // Cara sederhana untuk mendeteksi adblocker
    var testAd = document.createElement('div');
    testAd.innerHTML = ' ';
    testAd.className = 'adsbox';
    document.body.appendChild(testAd);

    window.setTimeout(function() {
        if (testAd.offsetHeight === 0) {
            adblockDetected = true;
        }
        testAd.remove();

        if (adblockDetected) {
            console.log('AdBlock terdeteksi!');
        } else {
            console.log('Tidak ada AdBlock yang terdeteksi.');
        }
    }, 100);
})();