Stripchat Native Fullscreen - Smart Exit

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

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

You will need to install an extension such as Tampermonkey 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.

You will need to install a user script manager extension to install this script.

(Tôi đã có Trình quản lý tập lệnh người dùng, hãy cài đặt nó!)

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