ch_th

극장모드

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

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

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

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

})();