Stripchat Native Fullscreen - Smart Exit

Aciona o fullscreen nativo, mas permite sair e respeita a decisão do usuário.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         Stripchat Native Fullscreen - Smart Exit
// @namespace    http://tampermonkey.net/
// @version      1.7
// @description  Aciona o fullscreen nativo, mas permite sair e respeita a decisão do usuário.
// @author       Thiago
// @match        https://stripchat.com/*
// @match        https://*.stripchat.com/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    const STATE = {
        userExited: false, // Flag para saber se você saiu manualmente
        autoTried: false   // Para não ficar tentando em loop
    };

    const getFSButton = () => {
        return document.querySelector('button .icon-fullscreen-on')?.closest('button') ||
               document.querySelector('button .icon-fullscreen-off')?.closest('button');
    };

    const toggleNativeFS = (force = false) => {
        const fsButton = getFSButton();
        const isCurrentlyFS = !!document.fullscreenElement;

        if (fsButton) {
            // Se queremos entrar e não estamos, ou se for um toggle manual ('T')
            if (force || (!isCurrentlyFS && !STATE.userExited)) {
                fsButton.click();
            }
        }
    };

    // Escuta quando o estado de fullscreen muda (tecla Esc ou botão do site)
    document.addEventListener('fullscreenchange', () => {
        if (!document.fullscreenElement) {
            console.log('[SC-FS] Usuário saiu do modo tela cheia. Desativando auto-click.');
            STATE.userExited = true; // Bloqueia o auto-click até o próximo 'boot' ou atalho
        }
    });

    // Primeira interação: "Pega carona" no seu primeiro clique para ativar
    document.addEventListener('click', function once() {
        if (!STATE.autoTried) {
            toggleNativeFS();
            STATE.autoTried = true;
        }
        document.removeEventListener('click', once);
    }, { capture: true, once: true });

    // Atalho 'T' para forçar a entrada/saída manualmente
    document.addEventListener('keydown', (e) => {
        if (e.key.toLowerCase() === 't' && !['INPUT', 'TEXTAREA'].includes(document.activeElement.tagName)) {
            STATE.userExited = false; // Reseta a flag para permitir nova entrada
            toggleNativeFS(true);
        }
    });

    // Monitora se o player apareceu (MutationObserver leve)
    const observer = new MutationObserver(() => {
        if (!STATE.autoTried && getFSButton()) {
            toggleNativeFS();
            STATE.autoTried = true;
        }
    });

    observer.observe(document.body, { childList: true, subtree: true });
})();