Auto Expand Live Chat Replay

Auto Expand Live Chat Replay, 自动展开直播聊天回放

目前为 2024-01-20 提交的版本。查看 最新版本

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

async function liveChatExpand(expandObj) {
    expandObj.click();
}

const liveChatExpandInterval = setInterval(() => {

    var expandObj = document.getElementsByClassName("yt-spec-button-shape-next");

    for(var i=0; i<expandObj.length;i++){

       if(expandObj[i].getAttribute("aria-label")=="Hide chat replay"){
           stopLiveChatExpandInterval();
       }

       if(expandObj[i].getAttribute("aria-label")=="Show chat replay"){

           liveChatExpand(expandObj[i]);
           //
           stopLiveChatExpandInterval();
       }
    }
}, 100);

function stopLiveChatExpandInterval(){
   clearInterval(liveChatExpandInterval);
   console.warn("stopLiveChatExpandInterval");
}