Youtube - Auto Show Live Chat Replay

Youtube Auto Show Live Chat Replay, YT自动展开直播聊天回放

目前为 2024-02-18 提交的版本。查看 最新版本

// ==UserScript==
// @name         Youtube - Auto Show Live Chat Replay
// @namespace    http://tampermonkey.net/
// @version      2.5
// @description  Youtube Auto Show Live Chat Replay, YT自动展开直播聊天回放
// @author       Martin______X
// @match        https://www.youtube.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=youtube.com
// @grant        none
// @license      MIT
// ==/UserScript==

let $url = null;

const showLiveChatClick = async (expandObj) => {
    expandObj.click();
}
const idCheckLiveChatInterval = setInterval(() => {
    let url = document.URL;
    if($url != url){
        if(url.includes("watch?v=") || url.includes("/live_chat_replay")){
            let video_des = document.getElementsByClassName("watch-active-metadata style-scope ytd-watch-flexy style-scope ytd-watch-flexy")[0];
            if(video_des && video_des.hasAttribute("video-id")){
                let div = document.getElementById("show-hide-button");
                let show_hide_button = div.getElementsByTagName("BUTTON")[0];
                let chatframe = document.getElementById("chatframe");
                let innerHTML = chatframe.contentWindow.document.body.innerHTML;
                if(innerHTML == ""){
                    showLiveChatClick(show_hide_button);
                }
            }
        }
        $url = url;
    }
}, 100);