Stripchat Native Fullscreen - Smart Exit

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

이 스크립트를 설치하려면 Tampermonkey, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램을 설치해야 합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 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 });
})();