Stripchat Native Fullscreen - Smart Exit

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

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