Multi Tab Visibility

allowing to open many tabs without browser's knowing

이 스크립트를 설치하려면 Tampermonkey, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램을 설치해야 합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 유저 스크립트 관리자 확장 프로그램이 필요합니다.

(이미 유저 스크립트 관리자가 설치되어 있습니다. 설치를 진행합니다!)

Advertisement:

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

(이미 유저 스타일 관리자가 설치되어 있습니다. 설치를 진행합니다!)

Advertisement:

// ==UserScript==
// @name             Multi Tab Visibility
// @namespace        violentmonkey/tampermonkey script 
// @version          3.0
// @description      allowing to open many tabs without browser's knowing 
// @author           Ojo Ngono
// @include          *://*/*
// @icon             https://i.ibb.co.com/XJSPdz0/large.png
// @exclude          /^(https?:\/\/)([^\/]+\.)?((cloudflare|github|aliyun|reddit|bing|yahoo|microsoft|whatsapp|amazon|ebay|payoneer|paypal|skrill|stripe|stripecdn|tipalti|wise|discord|tokopedia|taobao|taboola|aliexpress|netflix|citigroup|spotify|bankofamerica|hsbc|blogger|(accounts|studio).youtube|atlassian|pinterest|twitter|x|live|linkedin|fastbull|tradingview|deepseek|chatgpt|openai|grok|bilibili|indodax|bmcdn6|fbsbx|googlesyndication|amazon-adsystem|pubmatic|gstatic).com|(greasyfork|openuserjs|telegram|wikipedia|lichess).org|(doubleclick|yahoo).net|proton.me|stripe.network|meta.ai|codepen.io|(shopee|lazada|rakuten|maybank|binance).*|(dana|ovo|bca.co|bri.co|bni.co|bankmandiri.co|desa|(.*).go).id|(.*).(edu|gov))(\/.*)/
// @exclude          /^https?:\/\/(?!(www\.google\.com\/(recaptcha\/|url)|docs\.google\.com\/|drive\.google\.com\/)).*google\..*/
// @exclude          /^https?:\/\/([a-z0-9]+\.)*(facebook|instagram|tiktok)\.com\/(?!(flx\/warn\/|linkshim\/|link\/v2)).*/
// @grant            none
// @license          Copyright OjoNgono
// ==/UserScript==


 (() => {
    'use strict';

    // =========================
    // Visibility
    // =========================

    Object.defineProperty(document, 'hidden', {
        configurable: true,
        get: () => false
    });

    Object.defineProperty(document, 'visibilityState', {
        configurable: true,
        get: () => 'visible'
    });

    document.hasFocus = () => true;

    // =========================
    // Block visibility listeners
    // =========================

    const blockedEvents = new Set([
        'visibilitychange',
        'webkitvisibilitychange',
        'mozvisibilitychange',
        'msvisibilitychange'
    ]);

    const originalAddEventListener =
        EventTarget.prototype.addEventListener;

    EventTarget.prototype.addEventListener =
        function(type, listener, options) {

        if (blockedEvents.has(type)) {

            const wrapped = function(e) {

                Object.defineProperty(document, 'hidden', {
                    configurable: true,
                    get: () => false
                });

                Object.defineProperty(document, 'visibilityState', {
                    configurable: true,
                    get: () => 'visible'
                });

                return listener.call(this, e);
            };

            return originalAddEventListener.call(
                this,
                type,
                wrapped,
                options
            );
        }

        return originalAddEventListener.call(
            this,
            type,
            listener,
            options
        );
    };

    // =========================
    // IntersectionObserver
    // =========================

    if (window.IntersectionObserver) {

        const OriginalIO = window.IntersectionObserver;

        window.IntersectionObserver =
            class extends OriginalIO {

            constructor(callback, options) {

                super((entries, observer) => {

                    entries.forEach(entry => {

                        try {

                            Object.defineProperty(
                                entry,
                                'isIntersecting',
                                {
                                    configurable: true,
                                    get: () => true
                                }
                            );

                            Object.defineProperty(
                                entry,
                                'intersectionRatio',
                                {
                                    configurable: true,
                                    get: () => 1
                                }
                            );

                        } catch(e) {}

                    });

                    callback(entries, observer);

                }, options);
            }
        };
    }

    // =========================
    // elementFromPoint fallback
    // =========================

    const originalElementFromPoint =
        document.elementFromPoint.bind(document);

    document.elementFromPoint = function(x, y) {

        const el = originalElementFromPoint(x, y);

        if (el) return el;

        return document.body;
    };

    // =========================
    // userActivation
    // =========================

    if (navigator.userActivation) {

        try {

            Object.defineProperty(
                navigator.userActivation,
                'isActive',
                {
                    configurable: true,
                    get: () => true
                }
            );

            Object.defineProperty(
                navigator.userActivation,
                'hasBeenActive',
                {
                    configurable: true,
                    get: () => true
                }
            );

        } catch(e) {}
    }

    // =========================
    // Neutralize blur
    // =========================

    window.onblur = null;
    document.onvisibilitychange = null;

    // =========================
    // Keep alive
    // =========================

    setInterval(() => {

        window.dispatchEvent(new Event('focus'));

        document.dispatchEvent(
            new Event('visibilitychange')
        );

    }, 15000);

})();