ch_th

극장모드

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==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; // 비디오 음소거
    });

})();