Stripchat Always Focus

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

Du musst eine Erweiterung wie Tampermonkey, Greasemonkey oder Violentmonkey installieren, um dieses Skript zu installieren.

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

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

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

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

Sie müssten eine Skript Manager Erweiterung installieren damit sie dieses Skript installieren können

(Ich habe schon ein Skript Manager, Lass mich es installieren!)

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.

(I already have a user style manager, let me install it!)

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