Stripchat Always Focus

Keeps Stripchat visible optimally (Combines best of v1.1 & v1.2)

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το 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         Stripchat Always Focus
// @namespace    http://tampermonkey.net/
// @version      1.3
// @description  Keeps Stripchat visible optimally (Combines best of v1.1 & v1.2)
// @author       Nam
// @match        *://stripchat.com/*
// @grant        none
// @run-at       document-start
// ==/UserScript==

(function () {
    'use strict';

    // Ưu điểm từ bản v1.2: Ghi đè bằng getter tự nhiên
    Object.defineProperty(document, 'hidden', {
        configurable: true,
        get: () => false
    });

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

    Document.prototype.hasFocus = function () {
        return true;
    };

    // Ưu điểm từ bản v1.1: Chặn tín hiệu gửi đến trang web khi đổi tab
    const visibilityEvents = ['visibilitychange', 'webkitvisibilitychange'];
    for (let eventName of visibilityEvents) {
        window.addEventListener(eventName, function(event) {
            event.stopImmediatePropagation();
        }, true);
        document.addEventListener(eventName, function(event) {
            event.stopImmediatePropagation();
        }, true);
    }

    window.addEventListener('blur', function(event) {
        if (event.target === window || event.target === document) {
            event.stopImmediatePropagation();
        }
    }, true);
})();