Greasy Fork is available in English.

Youtube - Auto Show Live Chat Replay

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

// ==UserScript==
// @name         Youtube - Auto Show Live Chat Replay
// @namespace    http://tampermonkey.net/
// @version      2.7
// @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;
let $__videoId = null;
const showLiveChatClick = (async (expandObj) => {
    expandObj.click();
});
const idCheckLiveChatInterval = setInterval(() => {
    let url = document.URL;
    if($url!=url){
       $__videoId = null;
       $url=url;
    }

    let video_des = document.getElementsByClassName("watch-active-metadata style-scope ytd-watch-flexy style-scope ytd-watch-flexy")[0];
    let videoId = "";
    if (video_des) {
        videoId = video_des.getAttribute("video-id");
    }
    if ($__videoId != videoId) {
        let expandObjArray = document.getElementsByClassName("yt-spec-button-shape-next");
        for (let i = 0; i < expandObjArray.length; i++) {
            let expandObj = expandObjArray[i];
            let id = expandObj.parentElement.parentElement.parentElement.id;
            if (id == "show-hide-button") {
                let chatObj = document.querySelector("#chat");
                if (chatObj.hasAttribute("collapsed")) {
                    showLiveChatClick(expandObj);
                } else {
                    console.warn("Live Chat Expanded!");
                    $__videoId = videoId;
                }
            }
        }
    }
}, 100);