ch_th

극장모드

スクリプトをインストールするには、Tampermonkey, GreasemonkeyViolentmonkey のような拡張機能のインストールが必要です。

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

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyUserscripts のような拡張機能のインストールが必要です。

このスクリプトをインストールするには、Tampermonkeyなどの拡張機能をインストールする必要があります。

このスクリプトをインストールするには、ユーザースクリプト管理ツールの拡張機能をインストールする必要があります。

(ユーザースクリプト管理ツールは設定済みなのでインストール!)

このスタイルをインストールするには、Stylusなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus などの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus tなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

(ユーザースタイル管理ツールは設定済みなのでインストール!)

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==UserScript==
// @name         ch_th
// @namespace    ch_th
// @version      0.0.1
// @description  극장모드
// @author       lc2122
// @match        https://chzzk.naver.com/*
// @match        https://lolcast.web.app/*
// @match        https://lolcast.kr/*

// ==/UserScript==

(function () {
    'use strict';
    let debug = false;

    let url = document.location.href;

    // 최상위 창(일반 치지직 시청)일 경우 스크립트 종료, 임베드(iframe) 환경에서만 실행
    let isTopWindow = window.self === window.top;
    if (isTopWindow) {
        return;
    }

    if (debug) console.log("chzzk embed", url);

    function waitForElement(selector, callback) {
        const existingElement = document.querySelector(selector);

        if (existingElement) {
            callback(existingElement);
        } else {
            const observer = new MutationObserver((mutationsList) => {
                const targetElement = document.querySelector(selector);
                if (targetElement) {
                    observer.disconnect();
                    callback(targetElement);
                }
            });

            observer.observe(document.documentElement, {
                childList: true,
                subtree: true,
            });
        }
    }

    let player = undefined;
    let handleVideoReadyFired = false;

    let handleVideoReady = function(){
        if (handleVideoReadyFired) return;
        handleVideoReadyFired = true;
        let viewmode_buttons = document.querySelectorAll(".pzp-pc__viewmode-button");
        if(viewmode_buttons.length == 1){
            viewmode_buttons[0].click();
        }
        else{
            // 치즈나이프와의 충돌 방지
            for (let i = 0; i < viewmode_buttons.length; i++) {
                let button = viewmode_buttons[i];
                if (button.getAttribute('aria-label') === '넓은 화면') {
                    button.click();
                    break;
                }
            }
        }

        // 채팅창 닫기 버튼 클릭
        let chatCloseButton = document.querySelector('[class^="live_chatting_header_button__"]');
        if (chatCloseButton) {
            chatCloseButton.click();
        }
    };

    waitForElement("video.webplayer-internal-video", function (node) {
        if (debug) console.log("found video player", node);
        player = node;
        if (player.readyState >= 2) {
            handleVideoReady();
        } else {
            player.addEventListener('loadedmetadata', function once() {
                player.removeEventListener('loadedmetadata', once);
                handleVideoReady();
            });
        }
        player.muted = true; // 비디오 음소거
    });

})();