Greasy Fork

Openrec チャット欄透明化 (全画面時のみ)

Openrec の全画面表示時にのみチャットを透明(見えなく)するユーザースクリプトです。

当前为 2025-03-08 提交的版本,查看 最新版本

// ==UserScript==
// @name         Openrec チャット欄透明化 (全画面時のみ)
// @namespace    http://tampermonkey.net/
// @version      1.1
// @description  Openrec の全画面表示時にのみチャットを透明(見えなく)するユーザースクリプトです。
// @match        https://www.openrec.tv/*
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    // 全画面表示かどうかを判定し、チャットの透明度を更新する関数
    const updateChatVisibility = () => {
        const chatContainers = document.querySelectorAll('.movie-page-chat-aside');
        chatContainers.forEach(el => {
            if (document.fullscreenElement) {
                // 全画面時:チャットを透明にする
                el.style.opacity = '0';
                // 必要に応じてクリック等のイベントも無効化
                // el.style.pointerEvents = 'none';
            } else {
                // 全画面でない場合:元の状態に戻す
                el.style.opacity = '';
                // el.style.pointerEvents = '';
            }
        });
    };

    // 全画面状態の変化を監視
    document.addEventListener('fullscreenchange', updateChatVisibility);

    // DOM の変化にも対応するため MutationObserver を利用
    const observer = new MutationObserver(() => {
        updateChatVisibility();
    });
    observer.observe(document.body, { childList: true, subtree: true });

    // 初回チェック
    updateChatVisibility();
})();