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 για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το 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 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 });
})();