YouTube chat filter&report&block

filter&report&block

2022-05-13 या दिनांकाला. सर्वात नवीन आवृत्ती पाहा.

// ==UserScript==
// @name         YouTube chat filter&report&block
// @namespace    null
// @version      1.1.2
// @description  filter&report&block
// @author       null
// @match        *://*.youtube.com/*
// @grant        GM_registerMenuCommand
// @grant        GM_unregisterMenuCommand
// @grant        GM_addStyle
// ==/UserScript==
(function () {
    'use strict';
    if (window.location.pathname !== "/live_chat"&&window.location.pathname !== "/live_chat_replay") return;
    if (window.location.pathname!=window.parent.location.pathname)window.parent.document.querySelector("YTD-LIVE-CHAT-FRAME#chat").style.minHeight= "850px";
    let language = navigator.language,IsTranslation=false,sc
    const TNT = GM_registerMenuCommand(language_("Translate","翻译","翻訳"), () => {
        sc=window.parent.document.getElementById("sc-translator-shadow")||document.getElementById("sc-translator-shadow")
        if (sc){
            IsTranslation=IsTranslation?false:true
            alert(IsTranslation?language_("Translation:On","翻译功能:开","翻訳機能:On"):language_("Translation:Off","翻译功能: 关","翻訳機能:Off"))
            let EliteMiko=sc.shadowRoot.childNodes[4].querySelector(".st-result")
            let scc = new MutationObserver((node) => {
                node.forEach((me)=>{
                    if(!IsTranslation)return
                    me.addedNodes.forEach((you)=>{
                        if (you?.children?.length==1&&you?.children[0].nodeName=="SPAN"){
                            let selection = window.getSelection ? window.getSelection() : window.document.getSelection();
                            let messs=selection.focusNode
                            if(messs.id=="message"||!messs.nextSibling){
                                const Translate= messs.cloneNode()
                                messs.style.display = "none"
                                Translate.id="Translate"
                                Translate.style.color="rgb(0, 200, 255)"
                                Translate.innerText = you.innerText
                                messs.after(Translate)
                            }else if(messs.id="key_mes_p"){
                                messs.style.color="rgb(0, 200, 255)"
                                messs.innerText = you.innerText
                            }
                        }
                    })
                })
            });
            scc.disconnect();
            scc.observe(EliteMiko,{
                childList: true
            });
        }else{
            alert(language_("ScTranslate is not installed","未安装sc翻译插件","ScTranslateがインストールされていません"))
        }
    });
    let IsOwner=false,IsMod=false,Isnormal=false,Ismember=true,Account_Type
    let Isspecial=document.querySelector("div#top")?.querySelector("#author-name")
    if(Isspecial){
        Isspecial.className=="owner style-scope yt-live-chat-author-chip"?IsOwner=true:IsOwner=false
        Isspecial.className=="moderator style-scope yt-live-chat-author-chip"?IsMod=true:IsMod=false
        if(IsMod){
            const mod_ = GM_registerMenuCommand(language_("Moderator Mode","主持人模式","モデレーターモード"), () => {
                document.querySelector("#Auto_Report").checked=false
                document.querySelector("#ReportSET").innerText=language_("Off","关闭","Off");
                document.querySelector("#A_Report").style.visibility = "hidden";
                Mod_Runing?Mod_Runing=0:Mod_Runing=1
                alert(Mod_Runing?language_("Moderator Mode:ON","主持人模式:ON","モデレーターモード:ON"):language_("Mod Mode:OFF","主持人模式:OFF","モデレーターモード:OFF"))
            });
        }else if(IsOwner){
            const mod_2 = GM_registerMenuCommand(language_("Live Master Mode","主播模式","ライブマスターモード"), () => {
                document.querySelector("#Auto_Report").checked=false
                document.querySelector("#ReportSET").innerText=language_("Off","关闭","Off");
                document.querySelector("#A_Report").style.visibility = "hidden";
                Mod_Runing?Mod_Runing=0:Mod_Runing=1
                alert(Mod_Runing?language_("Live Master Mode:On","主播模式:ON","ライブマスターモード:ON"):language_("Live Master Mode:On","主持人模式:OFF","ライブマスターモー:OFF"))
            });
        }
    }
    const SET = GM_registerMenuCommand(language_("Detailed settings","详细设置","詳細設定"), () => {
        Set_()
    });
    let Keylist_trun = [],Anemati=[],Keylist_Re=[],Node_List=[],img_pvp=[],imgg = [],Node_Log_List = [],Block_URL=[],Del_List = [],Add_Items = [],Automatic=[]
    let ONOff=true,Script_ISrun=false,Achan=null,Bchan=null,Mod_dell=null,TTK=false,ClickBlock=false,Script_Running=false,ISclean=false,clean=false,old_Mode=1,Control_Mian=true,Control_Menu=true,Control_Dialogs=true,Block_=null;
    let log_1=0,log_2=0,log_3=0,log_4=0,log_5=0,Mod_Runing=0,outtime=1,rami=0,nethe=0,wait = 10000,ctm = 0,Ch_m = 0,spam=17,Mode=0,auto_p = 0,BlockIds=0,Node_List_index=0,Delete_interval = 1000
    let prpr,Kirara,Ame,Ina,Gura,Mori,color,Interval,Yagoo,Itemslist,color_ames,end,aki,korone,error,ISmanual,auto_p_n,log1,log2,log3,log4,log5,Blocked=null
    let Key_l = Number(localStorage.getItem("Key_l"))||16,BBQ = Number(localStorage.getItem("BBQ"))||3 ,Time = Number(localStorage.getItem("Time"))||20000
    let IsLogGet=localStorage.getItem("IsLogGet"),Isblock=localStorage.getItem("IsBlock"),Isreplace=localStorage.getItem("Isreplace")||"checked"
    let Main_Menu_Box, Dialogs_Confirm ,Report_Menu_report,Report_Menu_Item,BlockText,ProcessStarts = false
    let re = /[\u1F601-\u1F64F]|[\u0E00-\u0E7F]|<img.*src.*alt.*>|\[.{1,5}\]|[\[\]\-\_\,\!\|\.\~\`\(\)\#\$\%\^\&\*\+\-\{\}\:\;\"\<\>\@\?\\\/\s\=]|\’|\'/g
    //css
    GM_addStyle(".Report_Item{cursor:pointer;background-color:#0000;border-bottom:1px;border-style:solid;border-bottom-color:#22ff028c;overflow:auto;overflow-x:hidden;line-height :25px}")
    GM_addStyle(".P_key{cursor:pointer;text-indent:25px;width:100%;height:100%;display:inline-block;font-size:12px}")
    GM_addStyle("#key_mes{height:100%;overflow :scroll;overflow-x:auto}")
    GM_addStyle(".Title_top{width:100%;height:100%;text-align:center;display:inline-block;cursor:pointer}")
    GM_addStyle("#keyword_frame{overflow-y:auto;width:100%;height:100%;max-height:350px;overflow-x:hidden}")
    GM_addStyle("#automes{display:inline-flex;height:175px;width: 100%;flex-direction:row}")
    GM_addStyle("#img_box{overflow-y:auto;width:40%;height:100%;flex-grow:0}")
    GM_addStyle("#mes_box{overflow-y:auto;width:40%;height:100%;flex-grow:1;display:inline-flex;flex-direction:column}")
    GM_addStyle(".gura{overflow:auto;overflow-x:hidden;max-height:149px;line-height :17px}")
    GM_addStyle("#new_div_chat{overflow-y:auto;height:175px;overflow:scroll}")
    GM_addStyle(".Calliope{line-height:35px;height:20%;width:100%;display:inline-block}")
    GM_addStyle(".log{line-height:20px;height:20px;width:100%}")
    GM_addStyle("#settingitem{user-select:none}")
    GM_addStyle("#ChatMes,#Log,#dad:hover{cursor:pointer}")
    GM_addStyle(".pro{color: #93d2ff;font-size: 13px;text-align: center;line-height:15px}")
    GM_addStyle(".ppts{border-bottom:1px solid #666;font-size: 14px;line-height: 30px;text-indent:25px;color: #aaaaaa;}")
    GM_addStyle("#Set_off{font-size: 14px;line-height: 21px;text-align:center}")
    function css_white(){
        color = "rgba(0, 0, 0, 0.23)"
        GM_addStyle(".set_list{width:25%;height:25px;display:inline-block;background-color:rgba(75, 75, 75, 0.2);text-align:center;user-select:none;line-height:25px;cursor:pointer}")
        GM_addStyle(".set_item_list{height :25px;background-color:rgba(0, 0, 0, 0.23);text-indent: 10px;line-height:25px;cursor:pointer;;font-size:13px}")
        GM_addStyle(".MainWindow_css{height:250px;overflow:hidden;border-bottom:1px;border-style:solid;border-bottom-color:#0241ff;display:inline-flex;flex-direction:column;overflow:hidden}")
        GM_addStyle("textarea{resize: none;width:100%;height:169px;overflow-x:hidden;border-left:0px;border-top:0px;border-right:0px;border-bottom:0px;color:#000000;background-color:#f9f9f9}")//
        GM_addStyle(".auto_mes_p{padding: 2px 0;line-height: 18px;border-bottom:1px;border-style:solid;border-bottom-color:#00000075}")
        GM_addStyle("#other{overflow-y:auto;width:20%;height:100%;flex-grow:0;background-color:rgba(0, 0, 0, 0.23);text-align:center}")
    }
    function css_black(){
        color = "#4b4b4b"
        GM_addStyle(".set_list{width:25%;height:25px;display:inline-block;background-color:#363333;text-align:center;user-select:none;line-height:25px;cursor:pointer}")
        GM_addStyle(".set_item_list{height :25px;background-color:#4b4b4b;text-indent: 10px;;line-height:25px;cursor:pointer;font-size:13px}")
        GM_addStyle(".MainWindow_css{height:250px;overflow:hidden;border-bottom:1px;border-style:solid;border-bottom-color:#ff00006e;display:inline-flex;flex-direction:column;overflow:hidden}")
        GM_addStyle("textarea{resize: none;width:100%;height:169px;overflow-x:hidden;border-left:0px;border-top:0px;border-right:0px;border-bottom:0px;color:#FFFFFF;background-color:#181818}")//
        GM_addStyle(".auto_mes_p{padding: 2px 0;line-height: 18px;border-bottom:1px;border-style:solid;border-bottom-color:#cec0ff78}")
        GM_addStyle("#other{overflow-y:auto;width:20%;height:100%;flex-grow:0;background-color:#4b4b4b;text-align:center}")
    }
    /////////////////////////////////////////////////language/////////////////////////////////////
    function language_(en,zh,jp) {
        switch (language) {
            case "en-US":
                return en
            case "zh-CN":
                return zh
            case "ja":
                return jp
            default:
                return en
        }
    }
    //////////////////////////////////////////////////////////////////////////////////////////////
    launch()
    function launch() {
        const New_Chat_Frame = document.querySelector("#contents.yt-live-chat-renderer");
        const Allmes =document.querySelector("#contents")
        if (New_Chat_Frame){
            switch (window.getComputedStyle(New_Chat_Frame, null)?.getPropertyValue('border-color'))
            {
                case "rgb(255, 255, 255)":
                    css_black()
                    color_ames="#ffffff"
                    break;
                case "rgb(3, 3, 3)":
                    css_white()
                    color_ames="#000000"
                    break;
            }
        }
        Itemslist = document.querySelector("#items.yt-live-chat-item-list-renderer");
        if (!Itemslist) return;
        const DMM=localStorage.getItem("IMGitem");
        const Important_Frame = document.createElement("div");
        Important_Frame.id = "MainWindow";
        Important_Frame.setAttribute("class","MainWindow_css");
        const shion = document.createElement("div");
        const Setting = document.createElement("div");
        const Settinglist = document.createElement("div");
        const SettingItem = document.createElement("div")
        const O_Item = document.createElement("div");
        const shion_p = document.createElement("span");
        O_Item.style.flexGrow="1";
        O_Item.style.height = "175px";
        Setting.id = "setting";
        shion.id="state"
        shion.setAttribute("class","set_item_list")
        shion_p.id="tex"
        Settinglist.id = "settinglist";
        SettingItem.id = "settingitem";
        for (let i=0;i<4;i++){
            const set_List = document.createElement("div");
            const set_Item_List = document.createElement("div");
            const Title = document.createElement("span");
            Title.setAttribute("class","Title_top");
            set_List.setAttribute("class","set_list");
            set_Item_List.setAttribute("class","set_item_list");
            set_Item_List.style.display = "none";
            switch (i)
            {
                case 0:
                    set_List.id = "Input_Key_List";
                    set_Item_List.id = "Input_Key_Item";
                    set_Item_List.style.display = "";
                    Title.innerHTML = language_("Keys","关键词","キーワード")
                    Title.id = "T1";
                    break;
                case 1:
                    set_List.id = "gauging";
                    set_Item_List.id = "gauging_Item";
                    Title.innerHTML = language_("Comment","评论","コメント");
                    Title.id = "T2";
                    break;
                case 2:
                    set_List.id = "report_T";
                    set_Item_List.id = "report_Item";
                    Title.innerHTML = language_("Report","举报","報告");
                    Title.id = "T3";
                    break;
                case 3:
                    set_List.id= "Speech";
                    set_Item_List.id = "speech_Item";
                    Title.innerHTML = language_("Speech","报告","スピーチ");
                    Title.id = "T4";
                    break;
            }
            Settinglist.appendChild(set_List);
            set_List.appendChild(Title);
            SettingItem.appendChild(set_Item_List);
        }
        shion_p.innerText = language_("Save keywords to local text for next use","手动保存关键词到本地文本文档以备下次使用","キーワードをローカルテキストに保存してください");
        shion.appendChild(shion_p);
        Setting.appendChild(Settinglist);
        Setting.appendChild(SettingItem);
        Important_Frame.appendChild(Setting);
        Important_Frame.appendChild(shion);
        New_Chat_Frame.before(Important_Frame);
        const MainWindow = document.getElementById("MainWindow");
        const self= document.querySelector("div#top")?.querySelector("yt-live-chat-author-chip")
        let my = self?.querySelector("#author-name")
        if(my){
            my.style.cursor = "pointer"
            my.onclick = (e)=>{
                if (IsMod||IsOwner){
                    my.style.background="#aa02f7";
                    Mod_Runing?Mod_Runing=0:Mod_Runing=1
                    Mod_Runing?my.style.background="#aa02f7":my.style.background=""
                    IsMod&&alert(Mod_Runing?language_("Moderator Mode:ON","主持人模式:ON","モデレーターモード:ON"):language_("Mod Mode:OFF","主持人模式:OFF","モデレーターモード:OFF"))
                    IsOwner&&alert(Mod_Runing?language_("Live Master Mode:On","主播模式:ON","ライブマスターモード:ON"):language_("Live Master Mode:On","主持人模式:OFF","ライブマスターモー:OFF"))
                    let myname = my.innerText
                    }
            }
        }
        const Inputs = document.getElementById("Input_Key_Item");
        const Report_Frame= document.getElementById("report_Item");
        const gauging_Item = document.getElementById("gauging_Item");
        const speech_Item= document.getElementById("speech_Item");
        const speech_Item_0 = document.createElement("div");
        const speech_Item_p1= document.createElement("span");
        const speech_Item_p2= document.createElement("span");
        const speech_Item_p3= document.createElement("span");
        let Null_div = document.createElement("div");
        Null_div.style.display = "none";
        Inputs.style.display="none"
        gauging_Item.style.display=""
        speech_Item_0.id="Time_Set"
        speech_Item_0.appendChild(speech_Item_p1)
        speech_Item_0.appendChild(speech_Item_p2)
        speech_Item_0.appendChild(speech_Item_p3)
        speech_Item_p1.innerText= language_("Interval:(","间隔:(","間隔:(");
        speech_Item_p2.id = "Ti"
        speech_Item_p2.setAttribute('contenteditable', 'true')
        speech_Item_p2.innerText= Time/1000
        speech_Item_p3.innerText= language_(")Sec",")秒",")Sec");
        speech_Item.appendChild(speech_Item_0);
        speech_Item_p2.addEventListener('keydown', function (e) {if(e.keyCode == 13)speech_Item_p2.blur()})
        const TItle_1= document.getElementById("Input_Key_List");
        const TItle_2= document.getElementById("gauging");
        const TItle_3= document.getElementById("report_T");
        const TItle_4= document.getElementById("Speech");
        const Report_SET = document.createElement("div");
        const Report_key_mes = document.createElement("div");
        const gauging_0 = document.createElement("div");
        const gauging_1 = document.createElement("div");
        const gauging_00 = document.createElement("span");
        const gauging_01 = document.createElement("span");
        const gauging_02 = document.createElement("span");
        const gauging_10 = document.createElement("span");
        const gauging_11 = document.createElement("span");
        const gauging_12 = document.createElement("span");
        gauging_0 .style.display = "inline-block";
        gauging_0.id = "Key_l"
        gauging_00.innerText = language_("Filter comment greater than:","过滤出大于这个数的评论:","コメントの長さ:");
        gauging_01.innerText = Key_l
        gauging_01.setAttribute('contenteditable', 'true')
        gauging_01.addEventListener('keydown', function (e) {if(e.keyCode == 13)gauging_01.blur()})
        gauging_0.style.textIndent="0px";
        gauging_1.style.display = "inline-block";
        gauging_1.id = "BBQ"
        gauging_10.innerText = language_("Consecutive Times:","连续次数:","連打回数:");
        gauging_11.innerText = BBQ
        gauging_11.setAttribute('contenteditable', 'true')
        gauging_12.innerText = ""
        gauging_11.addEventListener('keydown', function (e) {if(e.keyCode == 13)gauging_11.blur()})
        gauging_0.appendChild(gauging_00);
        gauging_0.appendChild(gauging_01);
        gauging_0.appendChild(gauging_02);
        gauging_1.appendChild(gauging_10);
        gauging_1.appendChild(gauging_11);
        gauging_1.appendChild(gauging_12);
        gauging_Item.appendChild(gauging_0);
        gauging_Item.appendChild(gauging_1);
        Report_SET.id = "report_";
        Report_SET.style.display="inline-flex";
        Report_SET.style.textIndent= "0px";
        const Report_SET_0 = document.createElement("span");
        const Report_SET_1 = document.createElement("span");
        const Report_SET_2 = document.createElement("div");
        const Report_SET_2_p = document.createElement("span");
        const Report_SET_0_Input = document.createElement("input");
        Report_SET_0_Input.type="checkbox";
        Report_SET_0_Input.id = "Auto_Report";
        Report_SET_0.innerHTML= language_("Simplification","流程简化","簡素化");
        Report_SET_0.appendChild(Report_SET_0_Input);
        Report_SET_1.innerHTML= language_("👈On","👈开启","👈On");
        Report_SET_1.id = "ReportSET"
        Report_SET_2_p.id = "dad"
        Report_SET_2.style.textAlign="center";
        Report_SET_2.id = "A_Report"
        Report_key_mes.id = "key_mes";
        Report_key_mes.style.display = "none";
        Report_SET_2.appendChild(Report_SET_2_p);
        Report_SET.appendChild(Report_SET_0);
        Report_SET.appendChild(Report_SET_1);
        Report_Frame.appendChild(Report_SET);
        Report_SET.appendChild(Report_SET_2);
        MainWindow.appendChild(O_Item);
        const New_Chat = document.createElement("div");
        const Keyword_Frame = document.createElement("div");
        const Auto_mes = document.createElement("div");
        const Keyword_Frame_Textarea = document.createElement("textarea");
        Keyword_Frame_Textarea.id = "keys"
        const Auto_mes_L = document.createElement("div");
        Auto_mes_L.id = "img_box";
        const Auto_mes_O = document.createElement("div");
        const Auto_mes_O_P = document.createElement("span");
        const Auto_mes_R= document.createElement("div");
        const Auto_mes_log= document.createElement("div");
        const Auto_mes_log_x= document.createElement("div");
        Auto_mes_log.style.display="none"
        Auto_mes_log.style.width="40%"
        Auto_mes_O.id = "other";
        Auto_mes_O_P.innerHTML = language_("Ready","就绪","就绪");
        Auto_mes_O_P.title = language_("Send a random comment","随机发送一条评论","ランダムなコメントを送信する");
        Auto_mes_O_P.id= "TTi"
        Auto_mes_O_P.style.textIndent="5px"
        Auto_mes_O_P.style.cursor="pointer"
        Auto_mes_log.appendChild(Auto_mes_log_x);
        self&&self.appendChild(Auto_mes_O_P);
        Auto_mes_R.id = "mes_box";
        Auto_mes.id = "automes";
        Auto_mes.appendChild(Auto_mes_L);
        Auto_mes.appendChild(Auto_mes_O);
        Auto_mes.appendChild(Auto_mes_R);
        Auto_mes.appendChild(Auto_mes_log);
        Auto_mes.style.display = "none";
        New_Chat.id = "new_div_chat";
        Keyword_Frame.style.display = "none";
        Keyword_Frame.id = "keyword_frame";
        Keyword_Frame_Textarea.placeholder = language_("Paste keywords here and click Add","复制关键词到这后点添加","ここにキーワードを貼り付けて、[Add]をクリックします");
        Keyword_Frame.appendChild(Keyword_Frame_Textarea);
        O_Item.appendChild(Keyword_Frame);
        O_Item.appendChild(New_Chat);
        O_Item.appendChild(Report_key_mes);
        O_Item.appendChild(Auto_mes);
        let Chat=document.getElementById("new_div_chat")
        for (let i=0;i<5;i++){
            const Mori = document.createElement("div");
            const Mori_p = document.createElement("span");
            Mori_p.setAttribute('class', 'Calliope')
            switch (i)
            {
                case 0:
                    Mori_p.id = "ChatMes"
                    Mori_p.innerText=language_("Call","Call","Call");
                    break;
                case 1:
                    Mori_p.id = "Log"
                    Mori_p.innerText=language_("Data","Data","Data");
                    break;
            }
            Mori.appendChild(Mori_p);
            Auto_mes_O.appendChild(Mori);
        }
        for (let i=0;i<5;i++){
            const Log_p = document.createElement("span");
            const Log_p_0 = document.createElement("span");
            const Log_div = document.createElement("div")
            Log_p.setAttribute('class', 'log')
            Log_p_0.id = "Log_"+(i+1)
            switch (i)
            {
                case 0:
                    Log_p.innerText=language_("Spam:","Spam:","Spam:");
                    Log_p_0.innerText = 0
                    break;
                case 1:
                    Log_p.innerText=language_("Account:","Account:","Account:");
                    Log_p_0.innerText = ""
                    break;
            }
            Log_div.appendChild(Log_p);
            Log_div.appendChild(Log_p_0)
            Auto_mes_log_x.appendChild(Log_div);
        }
        log1 = document.getElementById("Log_1")
        log2 = document.getElementById("Log_2")
        log2.style.overflowY="scroll"
        log2.style.height="135px";
        log2.innerText = BlockIds
        log3 = document.getElementById("Log_3")
        log4 = document.getElementById("Log_4")
        log5 = document.getElementById("Log_5")
        if (DMM){img_pvp=DMM.split("|")
                 for (let item of img_pvp){
                     imgg=item.split(",")
                     imgset(imgg)
                     auto_p += 1
                 }
                }
        const Key_Frame = document.getElementById("keyword_frame")
        const Add_Input_Key = document.createElement("input")
        Add_Input_Key.id = "add_i_key";
        Add_Input_Key.type = "text";
        Add_Input_Key.placeholder = language_("Enter keyword","输入单条关键词","キーワードを入力してください");
        Add_Input_Key.maxlength = "500"
        Inputs.appendChild(Add_Input_Key)
        const Get_Key = document.getElementsByClassName("add_key")
        const Add_Button = document.createElement("input")
        Add_Button.type = "button"
        Add_Button.value = "Add"
        Add_Button.id = "add_b_key"
        Inputs.appendChild(Add_Button)
        const Del_Button = document.createElement("input")
        Del_Button.type = "button"
        Del_Button.value = "Delete:"+Keylist_Re.length
        Del_Button.id = "delete_key"
        Inputs.appendChild(Del_Button)
        const Addrun = document.getElementById("overflow")
        const Re = document.createElement("input")
        Re.type = "button"
        Re.id = "on_off"
        Re.value = language_("Hide","Hide","Hide");
        Addrun.before(Re)
        let counter = document.createElement("span")
        counter.id = "miko"
        counter.innerHTML = 0
        let Report_l = document.createElement("span")
        Report_l.id = "nrn"
        Report_l.innerHTML = log_2
        let kanata = document.createElement("div")
        kanata.style.display="inline-block"
        let kanata_1 = document.createElement("div")
        kanata.style.cssText+="font-size:12px"
        Re.before(kanata)
        const rami_1 = document.createElement("span")
        const rami_2 = document.createElement("span")
        const rami_T = document.createElement("span")
        rami_1.innerText="MSG:"
        rami_2.innerText="AUTO:"
        rami_T.innerText="=>"
        rami_T.style.cssText+="font-size:15px"
        rami_T.title="Click to Arrange"
        rami_T.style.cssText+="user-select:none"
        kanata_1.appendChild(rami_1)
        kanata_1.appendChild(counter)
        kanata_1.appendChild(rami_T)
        kanata_1.appendChild(rami_2)
        kanata_1.appendChild(Report_l)
        kanata.appendChild(kanata_1)
        /////////////////////////Detailed settings /////////////////////////////////
        let bo =document.querySelector("yt-live-chat-app")
        let TOP_div = document.createElement("div")
        TOP_div.id = "TOPdiv"
        TOP_div.style.position="absolute"
        TOP_div.style.background="rgba(33, 33, 33,0.92)"
        TOP_div.style.visibility="hidden"
        TOP_div.innerHTML+='<div style="height: 50px;"><div style="color: rgb(255, 255, 255);text-align:right;padding-top: 5px;padding-right: 10px;"><span id="Set_off" style="display: inline-block;cursor:pointer;width: 21px;height: 21px">×</span></div></div>'
        TOP_div.innerHTML+='<div style="height: 30px;width: 100%;display: inline-flex"><div class="ppts" style="width: 85%;"><span>'+
            language_("Report/Remove and Block","举报/删除并屏蔽","レポート/削除とブロック")
            +'</span></div><div class="ppts" style="width: 15%;overflow-y: scroll;overflow-x: hidden;"><input id="ISblock" type="checkbox" '+Isblock+'></div></div>'
        TOP_div.innerHTML+='<div style="height: 30px;width: 100%;display: inline-flex"><div class="ppts" style="width: 85%;"><span>'+
            language_("Replace chat comments","替换聊天评论","チャットコメントを置き換える")
            +'</span></div><div class="ppts" style="width: 15%;overflow-y: scroll;overflow-x: hidden;"><input id="ISreplace" type="checkbox" '+Isreplace+'></div></div>'
        TOP_div.innerHTML+='<div style="height: 30px;width: 100%;display: inline-flex"><div class="ppts" style="width: 85%;"><span>'+
            language_("Get Log","获取log","ログを取得")
            +'</span></div><div class="ppts" style="width: 15%;overflow-y: scroll;overflow-x: hidden;"><input id="Log_Get" type="checkbox" '+IsLogGet+'></div></div>'
        TOP_div.innerHTML+='<div style="height: 30px;width: 100%;display: inline-flex"><div class="ppts" style="width: 85%;"><span>'+
            language_("Show Log","输出log","ログを表示")//////////////////////////////////////
            +'</span></div><div class="ppts" style="width: 15%;overflow-y: scroll;overflow-x: hidden;"><input id="Log_Show" type="checkbox"></div></div>'
        TOP_div.innerHTML+='<div style="width: 100%;height: 10px;background-color:#f9f9f947"></div>'
        TOP_div.innerHTML+=	'<div id="antetype_mes" style="width: 100%; display: none; flex-direction: column; border-top-width: 1px; border-left-width: 1px;border-left-style: solid;border-top-style: solid;"class="ppts"><div style="display: inline-flex; width: 100%"><div id="Log_Name" style="width: 85%;"></div><div id="antetype" style="width: 15%;text-align: right;"><input id="Unblock" type="checkbox"></div></div><div id = "Log_Comment" style="text-indent: 25px;width: 85%;"></div></div>'
        TOP_div.innerHTML+='<div style=" border-bottom-width: 0px; width: 100%;height: 50px;background-color:#f9f9f930" class="ppts"><div id = "Sort">'
            + language_("Sort type:","排序:","ソートタイプ:")+'<select id="Category_sort"><option value="name">'+ language_("Name","名字","名前")
            +'</option><option value="name_abc">'+language_("Initials","字首字母","イニシャル")+'</option><option value="Mes_length">'+ language_("Comment Word Count","评论字数","コメントの単語数") +'</option></select>' + language_("  Type","  种类:","  タイプ:")+'<select id="Classification"><option value="Null">ALL</option><option value="block_ed">'+ language_("Blocked","已屏蔽","ブロックした")
            +'</option><option value="report_ed">'+language_("Reported","已举报","報告した")+'</option><option value="URL_">'+ language_("Channel URL","频道网址","チャネルURL") +'</option></select></div>'
        TOP_div.innerHTML+='<div></div>'
        TOP_div.innerHTML+='</div>'
        TOP_div.innerHTML+='<div id="Block_Logs" style="overflow-y: scroll;overflow-x: hidden;"></div>'
        TOP_div.innerHTML+='</div><div id="Dump" style="display:none"></div>'
        TOP_div.innerHTML+='</div>'
        bo.appendChild(TOP_div)
        let pro = document.createElement("div")
        pro.id = "Pro"
        pro.style.position="absolute"
        pro.style.background="rgba(0, 0, 0,0)"
        MainWindow.appendChild(pro)
        pro.innerHTML = '<div style="height: 235px;"></div><div id="PRO_1" class="pro" style="height: 15px;background:rgba(75,75,75,0.7)"></div>'
        /////////////////////function/////////////////
        function imgset(item){
            let Auto_mes_R = document.querySelector("#mes_box")
            const Auto_mes_P = document.createElement("span")
            Auto_mes_R.appendChild(Auto_mes_P)
            auto_p_n= "auto_p"+auto_p
            Auto_mes_P.id = "auto_p"+auto_p
            Auto_mes_P.setAttribute('contenteditable', 'true')
            Auto_mes_P.setAttribute('class', 'auto_mes_p')
            Auto_mes_P.onblur = function (){if (Auto_mes_P.innerHTML=="") Auto_mes_P.remove()}
            for(let img of item ){
                Auto_mes_P.innerHTML=img
            }
        }
        function Report(mes,cdk,key_i,Timer,index){
            Keylist_Re=AddKey_List(cdk,Keylist_Re)
            Node_List[index].Isspam=true;
            Mod_Runing&&Queue(mes,index)
            Del_List =[...new Set(Del_List)]
            setTimeout(()=>{
                mes.querySelector("#message").removeAttribute("style")
                mes.querySelector("#ZOO").style.display = "none"
                let T_1 = document.createElement("div")
                let T_2 = document.createElement("div")
                let p_1 = document.createElement("span")
                let Div_Index = document.createElement("div")
                let ID_key= "key_uid"+key_i
                let Mes_key= "mes_uid"+key_i
                T_1.id =ID_key
                T_2.id = Mes_key
                Div_Index.id= index
                T_2.setAttribute('class', 'gura')
                T_2.style.display = "none"
                T_1.setAttribute("class","Report_Item")
                p_1.innerText=Keylist_trun[key_i].replace(/(\.\*)/g, "")
                p_1.title = language_("Click to expand | Double click to delete","单击展开|双击删除","クリックして展開|ダブルクリックして削除");
                p_1.id = "key_mes_p"
                p_1.setAttribute("class","P_key")
                T_1.appendChild(p_1)
                let TNT=Null_div.cloneNode()
                Itemslist.appendChild(TNT)
                Report_l.innerHTML=Report_key_mes.querySelectorAll("yt-live-chat-text-message-renderer").length
                Div_Index.appendChild(mes)
                let Mes_list = document.getElementById(Mes_key);
                if(Mes_list){
                    Mes_list.appendChild(Div_Index)
                }else {
                    T_2.appendChild(Div_Index)
                    T_1.appendChild(T_2)
                    Report_key_mes.appendChild(T_1)
                }
            },Timer*1000+7000)
        }
        function pekoname(name,mes_,Timer,index){
            let repeat=index-BBQ
            for (let i = index,L = repeat<0?0:repeat;i>=L;i--){
                if (Node_List[i].name==name&&i!=index){
                    let Cdk=Node_List[i].Message.replace(re, "")
                    let cdk=GetKey(Cdk)
                    if(Cdk!=mes_)Keylist_trun=AddKey_List(cdk,Keylist_trun)
                    Keylist_Re=AddKey_List(cdk,Keylist_Re)
                    Report(Node_List[i].node,cdk,key_i(cdk),Timer+1,i)
                    Node_List[i].Isspam=true
                }
            }
        }

        function AddItems(mes,username,Ch_m,get_time,Timer,index) {
            let Time = Mod_Runing?0:Timer*1000+6000
            let a=setTimeout(()=>{
                mes.querySelector("#message").removeAttribute("style")
                mes.querySelector("#ZOO").style.display = "none"
                let gdp = document.createElement("div")
                let key_list = document.createElement("div")
                let gdp_in_Top = document.createElement("div")
                let gdp_in_Fold = document.createElement("div")
                let gdp_in_L = document.createElement("div")
                let gdp_in_O = document.createElement("div")
                let gdp_in_index = document.createElement("div")
                gdp_in_index.id = index
                gdp_in_Top.id = "TOP"
                gdp_in_Fold.id = "Fold"
                gdp_in_Fold.style.display = "none"
                gdp_in_L.id = "L"
                gdp_in_L.style.display = "inline-block"
                gdp_in_L.style.width = "4%"
                gdp_in_O.id = "O"
                gdp_in_O.style.display = "inline-block"
                gdp_in_O.style.width = "96%"
                key_list.id = get_time+"&"+Ch_m+"&"+index
                gdp.id = username
                gdp.setAttribute("class","Mio")
                key_list.setAttribute("class","Tako")
                let TNT=Null_div.cloneNode()
                Itemslist.appendChild(TNT)
                let m=New_Chat.firstElementChild?.id||"0&0"
                let tako = m.split("&")
                let Kronii_new=Number(get_time)
                let Kronii_Old=Number(tako[0])
                if(Kronii_new-Kronii_Old<0)Kronii_new+=60
                let T=Kronii_new-Kronii_Old
                if (Number(Ch_m)<BBQ&&Math.abs(T)<=1&&Number(tako[1])<=BBQ){
                    let ol=New_Chat?.firstElementChild?.querySelector("#message")
                    if(ol)ol.style.color = "red"
                    mes.querySelector("#message").style.color = "red"
                }
                gdp_in_index.appendChild(mes)
                gdp_in_Top.appendChild(gdp_in_index)
                gdp.appendChild(gdp_in_Top)
                key_list.appendChild(gdp)
                Mod_Runing||Script_ISrun?New_Chat.append(key_list):New_Chat.prepend(key_list)
                gdp_in_Fold.appendChild(gdp_in_L)
                gdp_in_Fold.appendChild(gdp_in_O)
                gdp.appendChild(gdp_in_Fold)
                if (Node_List.length){
                    for (let i=0,l=Node_List.length;i<l;i++){
                        if(Node_List[i].name===username&&i!=index&&Node_List[i].Isspam==false){
                            let gdp_in__Fold_index = document.createElement("div")
                            gdp_in__Fold_index.id = i
                            gdp_in__Fold_index.appendChild(Node_List[i].node)
                            Node_List[index].IsFold= true
                            Node_List[i].IsFold = false
                            gdp_in_O.appendChild(gdp_in__Fold_index)
                            Node_List[i].node.querySelector("#message").style.color = "#f700ff"//////////////////////
                            mes.querySelector("#message").style.color = "#f700ff"
                        }
                    }
                }
            },Time)
            }
        //===================================================onev===============================================================================
        document.addEventListener('keydown', logKey);
        let Throttle
        function logKey(e) {
            if(!Mod_Runing&&!Script_ISrun)return
            switch (e.code)
            {
                case "ArrowRight":
                    if(Script_Running)return
                    clearTimeout(Throttle)
                    Throttle = setTimeout(()=>{
                        ISmanual=1;Control_Mian=true;Control_Menu=true;Control_Dialogs=true;
                        if(Mod_dell){
                            let Cdk=Mod_dell.querySelector("#message").innerText
                            let cdk= GetKey(Cdk);
                            let index = Number(Mod_dell.parentNode.id)
                            Keylist_Re=AddKey_List(cdk,Keylist_Re)
                            if(Mod_Runing){
                                let bba = document.createElement("div")
                                let mes_id = document.createElement("div")
                                mes_id.id = index
                                bba.style.display="none"
                                bba.setAttribute('class', 'gura')
                                bba.id = "ModD"
                                if(aki){
                                    mes_id.appendChild(Mod_dell)
                                    document.querySelector("#ModD").appendChild(mes_id)

                                }else{
                                    let dell = document.createElement("div")
                                    let span = document.createElement("span")
                                    dell.id = "mod_delete"
                                    dell.setAttribute("class","Report_Item")
                                    span.setAttribute("class","P_key")
                                    span.innerText=language_("Manually deleted comment","手动删除的评论","手動で削除されたコメント")
                                    mes_id.appendChild(Mod_dell)
                                    bba.appendChild(mes_id)
                                    dell.appendChild(bba)
                                    dell.prepend(span)
                                    Report_key_mes.prepend(dell)
                                    aki=document.querySelector("#mod_delete")
                                }
                            }
                            Mod_Runing?Queue(Mod_dell,index):automated(Node_List[Achan].node,Achan)
                        }else{
                            Mod_dell = Chat.querySelector("yt-live-chat-text-message-renderer")
                            if(Mod_dell){
                                Achan=Number(Mod_dell.parentNode.id)
                                New_Chat.scrollTop=0
                                if (Node_List[Achan].IsFold){
                                    let b=Mod_dell.parentNode.parentNode.nextSibling
                                    b.style.display = ""
                                }
                                pro.style.visibility = "hidden"
                                Mod_dell.parentNode.parentNode.style.display = "";
                                Mod_dell.querySelector("#message").style.fontSize="18px"
                                Mod_dell.querySelector("#message").style.fontWeight='bold'
                            }else{
                                Mes(language_("No Comment!","没有评论!","コメントなし!"))
                            }
                        }
                    },300)
                    break;
                case "ArrowLeft":
                    if(Script_Running)return
                    clearTimeout(Throttle)
                    Throttle = setTimeout(()=>{
                        if(Mod_dell){
                            Mod_dell.remove()
                            Mod_dell=null
                            Achan=null
                            Mes(language_("Comment skipped","已跳过评论","スキップしました"))
                        }else{
                            Mod_dell = Chat.querySelector("yt-live-chat-text-message-renderer")
                            if(Mod_dell){
                                New_Chat.scrollTop=0
                                Achan=Number(Mod_dell.parentNode.id)
                                if (Node_List[Achan].IsFold){
                                    let b=Mod_dell.parentNode.parentNode.nextSibling
                                    b.style.display = ""
                                }
                                pro.style.visibility = "hidden"
                                Mod_dell.parentNode.parentNode.style.display = "";
                                Mod_dell.querySelector("#message").style.fontSize="18px"
                                Mod_dell.querySelector("#message").style.fontWeight='bold'
                            }else{
                                Mes(language_("No Comment!","没有评论!","コメントなし!"))
                            }
                        }
                    },300)
                    break;
            }
        }
        New_Chat.onmouseover = function (e) {
            let E=e.target
            if (E.id == "message"||E.id=="Translate"){
                if(Script_ISrun){
                    if(!Kirara)e.target.title=Mode?language_("Double click to report this comment","双击举报评论","ダブルクリックしてコメントを報告する"):language_("Double click to block this user","双击屏蔽用户","ダブルクリックしてユーザーをブロックします");
                    if(Kirara)e.target.title =Mode?language_("Double click to report this comment and Block this user","双击举报评论并屏蔽用户","ダブルクリックしてコメントを報告する、ユーザーをブロックします"):language_("Double click to block this user","双击屏蔽用户","ダブルクリックしてユーザーをブロックします");
                    E.style.cursor="pointer"
                    E.style.userSelect="none"
                }else if(!Script_ISrun&&!Mod_Runing){
                    if(!Script_ISrun)e.target.title = ""
                    IsTranslation?e.target.title=language_("Translate this comment","翻译这段评论","コメントを翻訳する"):language_("Translating comments requires Sctranslate plugin","翻译评论需要sc翻译插件","コメントを翻訳するにはScTranslateが必要です")
                    E.style.cursor="help"
                    E.style.userSelect="text";
                }else if(Mod_Runing){
                    E.style.cursor="not-allowed"
                    e.target.title=language_("Delete comment","删除评论","コメントを削除")
                }
            }else{
                shion_p.innerText=null
            }
        }
        New_Chat.ondblclick =function(e){
            if(Mod_Runing) return
            if (Mod_Runing||(Script_ISrun&&(e.target.id == "message"||e.target.id=="Translate"))&&!korone&&!Script_Running){
                let selection = window.getSelection();
                selection.removeAllRanges();
                ISmanual=1
                let Cdk
                Achan=Number(e.target.parentNode.parentNode.parentNode.id)
                Control_Mian=true
                if(error==Achan){
                    error=confirm(language_("[OK] skip, [Cancel] try again","[确定]跳过,[取消]重试","[OK]スキップ、[キャンセル]再試行"))?null:Achan
                    ProcessStarts=false
                }else{
                    error=Achan
                }
                e.target.id=="Translate"?Cdk = e.target.previousSibling.innerText: Cdk=e.target.innerText
                let cdk= GetKey(Cdk);
                Keylist_Re=AddKey_List(cdk,Keylist_Re)
                if (error==null){
                    Node_List[Achan].node.remove()
                    Achan=null
                    return
                }else{
                    Mod_Runing?Queue(Node_List[Achan].node,Achan):automated(Node_List[Achan].node,Achan)
                }
                error=Achan
                Node_List[Achan].Isspam=true
                if (Node_List[Achan].IsFold){
                    let b=e.target.parentNode.parentNode.parentNode.parentNode.nextSibling
                    b.style.display = ""
                }
            }
        }
        Allmes.onclick = function (e){
            if(e.target.id == "message"||e.target.id=="Translate"){
                let NodeIndex=Number(e.target.parentNode.parentNode.parentNode.id)
                if(e.target.id=="Translate"){
                    let Tran=e.target.previousSibling
                    Tran.style.display = ""
                    e.target.style.display = "none"
                }else if(e.target.id =="message"){
                    let Tran =e.target.nextSibling
                    if (Tran.id=="Translate"){
                        Tran.style.display = ""
                        e.target.style.display = "none"
                    }
                }
                if(IsTranslation){
                    let selection = window.getSelection();
                    selection.removeAllRanges();
                    let range = new Range();
                    range.selectNodeContents(e.target);
                    selection.addRange(range);
                }
                if(Node_List[NodeIndex]?.IsFold){
                    let b=e.target.parentNode.parentNode.parentNode.parentNode.nextSibling
                    b&&b.style.display == "none"?b.style.display = "":b.style.display = "none"
                }
            }
        }
        Auto_mes_O_P.onclick=()=>{
            autocall(0,Time,true)
        }
        Auto_mes_L.onclick = function(e){
            if (e.target.nodeName=="IMG"){
                let img=document.createElement("img")
                img.src = e.target.src
                img.setAttribute('class', 'emoji yt-formatted-string style-scope yt-live-chat-text-input-field-renderer')
                img.style.cssText+="margin:-5px 2px;width:20px;height: 20px"
                img.alt= e.target.alt
                if (!auto_p_n){
                    const Auto_mes_P = document.createElement("span")
                    Auto_mes_R.appendChild(Auto_mes_P)
                    Auto_mes_P.id = "auto_p"+auto_p
                    Auto_mes_P.setAttribute('contenteditable', 'true')
                    Auto_mes_P.setAttribute('class', 'auto_mes_p')
                    Auto_mes_P.appendChild(img)
                    Auto_mes_P.onblur = function (y){if (Auto_mes_P.innerHTML=="") Auto_mes_P.remove()}
                    auto_p_n= "auto_p"+auto_p
                    auto_p += 1
                }else{
                    document.getElementById(auto_p_n)?.focus()
                    document.activeElement.appendChild(img)
                }
            }
        }
        Auto_mes.onmouseover = function(e){
            switch (e.target.id)
            {
                case "ChatMes":
                    e.target.title = language_("on/off Confrontation Mode","开/关 对喷模式!","on/off コールモード");
                    break;
                case "Log":
                    e.target.title = language_("無意味なデータ","無意味なデータ","無意味なデータ");
                    break;
                case "img_box":
                    e.target.title = language_("Click the emoji to add to content","点击表情加入评论内容","emojiをクリックしてコメントに追加");
            }
            let p =document.getElementById(auto_p_n)
            if (p){
                p.blur()
                auto_p_n=null
                localItem()
            }
            p=null
        }
        Auto_mes.onclick = function(e){
            switch (e.target.id)
            {
                case "ChatMes":
                    TTK?TTK=false:TTK=true
                    TTK?e.target.innerText="Confrontation":e.target.innerText="Call"
                    if(!TTK){
                        window.clearInterval(Interval)
                        outtime=1
                        Interval=null
                        Auto_mes_O_P.innerHTML = "Ready"
                    }
                    break;
                case "Log":
                    log2.innerText = BlockIds
                    Auto_mes_R.style.display == "none"?Auto_mes_R.style.display = "":Auto_mes_R.style.display = "none"
                    Auto_mes_log.style.display == ""?Auto_mes_log.style.display = "none":Auto_mes_log.style.display = ""
                    break;
            }
        }
        Auto_mes_R.onclick =function(e){
            if (e.target.nodeName=="SPAN"){
                auto_p_n=e.target.id
            }else {
                auto_p_n=null
                localItem()
            }
        }
        Add_Button.onclick = function addkey() {
            if (Add_Input_Key.value != ""){
                Keylist_trun.push(GetKey(Add_Input_Key.value))
                Add_Input_Key.value = ""
                Del_Button.value = "Delete:"+Keylist_Re.length
                Keyword_Frame_Textarea.value = Keylist_Re.join("\n").replace(/(\.\*)/g, "")
                return;
            }
            if (Keyword_Frame_Textarea.value!=""){
                let Keylist=Keyword_Frame_Textarea.value.split('\n')
                DellArray("",Keylist)
                Keylist=[...new Set(Keylist)]
                Keylist_trun = Keylist.map(item=>{return GetKey(item.replace(re, ""))}).concat(Keylist_trun)
                DellArray("",Keylist_trun)
                Keylist_trun=[...new Set(Keylist_trun)]
                Keylist_Re = Keylist.map(item=>{return GetKey(item.replace(re, ""))}).concat(Keylist_Re)
                DellArray("",Keylist_Re)
                Keylist_Re=[...new Set(Keylist_Re)]
                let key__=Keylist_Re.join("\n").replace(/(\.\*)/g, "")
                Del_Button.value = "Delete:"+Keylist_Re.length
                Keyword_Frame_Textarea.value = key__
            }
        }
        Add_Input_Key.onfocus = function () {
            Key_Frame.style.display = ""
            Keyword_Frame_Textarea.value = Keylist_Re.join("\n").replace(/(\.\*)/g, "")
        }
        Del_Button.onclick = function () {
            Keylist_trun = [];
            Keylist_Re=[];
            Del_Button.value = "Delete:"+Keylist_Re.length
            Keyword_Frame_Textarea.value = ""
        }

        Report_key_mes.ondblclick=function (e) {
            if (e.target.className == "P_key"&&!e.target.id!="mod_delete"){
                let x = e.target.parentNode.querySelector(".gura")
                x.style.display = "none"
                let key_del= e.target.innerText
                let key_i
                if (confirm(language_("Not Spam","不是Spam","スパムではない"))){
                    for (let i=0,l=Keylist_Re.length;i<l;i++){
                        let reg_kkey = new RegExp(Keylist_Re[i]);
                        if (reg_kkey.test(key_del)) {
                            key_i=i
                            break;
                        }
                    }
                    Keylist_Re.splice(key_i,1)
                    e.target.parentNode.remove()
                    return
                }
            }
        };
        Report_key_mes.onclick = function (e) {
            if (e.target.className == "P_key"){
                let selection = window.getSelection();
                selection.removeAllRanges();
                let range = new Range();
                range.selectNodeContents(e.target);
                selection.addRange(range);
                let x = e.target.parentNode.querySelector(".gura")
                x.style.display!="none" ? x.style.display = "none":x.style.display=""
            }
        }
        Report_SET_0_Input.onclick = function(){
            if(Mod_Runing){
                let mod_onoff=confirm(language_("This function cannot be used in moderator mode. Do you want to exit moderator mode?","主持人模式下无法使用此功能,是否退出主持人模式?","この機能はモデレーターモードでは使用できません。モデレーターモードを終了しますか"))
                if(mod_onoff){
                    Report_SET_0_Input.checked=true
                    Mod_Runing=0
                }else{
                    Report_SET_0_Input.checked=false
                    return
                }
            }
            Script_ISrun = Report_SET_0_Input.checked
            korone=null;Control_Mian=true;Control_Menu=true;Control_Dialogs=true;ISmanual=0;error=null;Script_Running=false;Achan=null;
            let of=Mode?language_("Report","举报","報告"):language_("Block","屏蔽","ブロック");
            Script_ISrun?Report_SET_1.innerText=language_("Mode:(","模式:(","モード:(")+of+")":Report_SET_1.innerText=language_("Off","关闭","Off");
            Report_SET_2_p.innerHTML=language_("👉Run Automated Scripts👈","👉运行自动脚本👈","👉自動スクリプトを実行する👈");
            Script_ISrun?Report_SET_2.style.visibility = "visible":Report_SET_2.style.visibility = "hidden"
        }
        Re.onclick = function () {
            switch (Re.value)
            {
                case "Hide":
                    MainWindow.style.display = "none"
                    Re.value = "View"
                    break;
                case "View":
                    MainWindow.style.display = ""
                    Re.value = "Hide"
                    break;
            }
        }
        Settinglist.onclick = function (e){
            switch (e.target.id)
            {
                case "T1":
                    if(Inputs.style.display="none" )Inputs.style.display="";
                    if (Inputs.style.display==""){
                        TItle_1.style.backgroundColor=color
                        TItle_2.removeAttribute("style")
                        TItle_3.removeAttribute("style")
                        TItle_4.removeAttribute("style")
                        Report_Frame.style.display="none"
                        gauging_Item.style.display = "none"
                        speech_Item.style.display = "none"
                        New_Chat.style.display = "none"
                        Report_key_mes.style.display = "none"
                        Auto_mes.style.display = "none"
                        Keyword_Frame.style.display = ""
                        Keyword_Frame_Textarea.value = Keylist_Re.join("\n").replace(/(\.\*)/g, "")
                        Del_Button.value = "Delete:"+Keylist_Re.length
                        shion_p.innerText= language_("Add single↑ or multiple↓ keywords","添加单条↑ 添加多条↓ 关键词","1つのキーワードを追加↑複数のキーワードを追加↓");
                    }
                    break;
                case "T2":
                    if(gauging_Item.style.display="none")gauging_Item.style.display="";
                    if (gauging_Item.style.display==""){
                        TItle_1.removeAttribute("style")
                        TItle_2.style.backgroundColor=color
                        TItle_3.removeAttribute("style")
                        TItle_4.removeAttribute("style")
                        Report_Frame.style.display="none"
                        Inputs.style.display = "none"
                        speech_Item.style.display = "none"
                        New_Chat.style.display = ""
                        Report_key_mes.style.display = "none"
                        Auto_mes.style.display = "none"
                        Keyword_Frame.style.display = "none"
                        shion_p.innerText= language_("Turn on Simplification,Click to comment to report","开启流程简化后点击评论举报","簡素化をオンにする,コメントをクリックして報告する");
                    }
                    break;
                case "T3":
                    if (Report_Frame.style.display="none")Report_Frame.style.display="";
                    if (Report_Frame.style.display==""){
                        TItle_1.removeAttribute("style")
                        TItle_2.removeAttribute("style")
                        TItle_3.style.backgroundColor=color
                        TItle_4.removeAttribute("style")
                        Inputs.style.display="none"
                        gauging_Item.style.display = "none"
                        speech_Item.style.display = "none"
                        New_Chat.style.display = "none"
                        Report_key_mes.style.display = ""
                        Auto_mes.style.display = "none"
                        Keyword_Frame.style.display = "none"
                        shion_p.innerText= language_("↓Click to expand | Double click to delete↓","↓单击展开|双击删除↓","↓クリックして展開|ダブルクリックして削除↓");
                        Report_l.innerHTML=Report_key_mes.querySelectorAll("yt-live-chat-text-message-renderer").length
                    }
                    break;
                case "T4":
                    if (speech_Item.style.display="none")speech_Item.style.display="";
                    if (speech_Item.style.display==""){
                        TItle_1.removeAttribute("style")
                        TItle_2.removeAttribute("style")
                        TItle_3.removeAttribute("style")
                        TItle_4.style.backgroundColor=color
                        Report_Frame.style.display="none"
                        gauging_Item.style.display = "none"
                        Inputs.style.display = "none"
                        New_Chat.style.display = "none"
                        Report_key_mes.style.display = "none"
                        Auto_mes.style.display = ""
                        Keyword_Frame.style.display = "none"
                        shion_p.innerText= language_("et interval and content","设置发言间隔","間隔を設定する");
                        iron_load()
                    }
                    break;
            }
        }
        SettingItem.onclick =function(e){
            if(e.target.nodeName=="SPAN"){
                let of
                switch (e.target.parentNode.id)
                {
                    case "Key_l":
                        gauging_01.focus();
                        gauging_01.innerText= "";
                        break;
                    case "BBQ":
                        gauging_11.focus();
                        gauging_11.innerText= "";
                        break;
                    case "Time_Set":
                        speech_Item_p2.focus();
                        speech_Item_p2.innerText= "";
                        break;
                    case "A_Report":
                        Automatic = [];
                        Report_key_mes.querySelectorAll("yt-live-chat-text-message-renderer").forEach((item)=>{
                            Automatic.push({node:item,index:Number(item.parentNode.id)})
                        })
                        if(Automatic.length){
                            Script_Running=true
                            automated();
                            Report_SET_2_p.innerText=language_("In Execution","执行中","実行中");
                        }
                        break;
                    case "report_":
                        if(!Script_ISrun) return
                        Mode=Mode?0:1;
                        old_Mode=Mode;
                        of=Mode?language_("Report","举报","報告"):language_("Block","屏蔽","ブロック");
                        Report_SET_1.innerText=language_("Mode:(","模式:(","モード:(")+of+")";
                        break;
                }
            }
        }
        SettingItem.onmouseover = function(e){
            if(e.target.nodeName=="SPAN"){
                switch (e.target.parentNode.id)
                {
                    case "Key_l":
                        e.target.title = language_("Set a number greater than 10","设置大于10的数","10より大きい数を設定");
                        break;
                    case "BBQ":
                        e.target.title = language_("Set a number greater than 1 and less than 10","设置大于1小于10的数字","1より大きく10より小さい数値を設定して");
                        break;
                    case "Time_Set":
                        e.target.title = language_("Set the interval, too fast will be judged as a robot","设置间隔,过快可能被判定为机器人","間隔を設定。速すぎるとロボットと判断される");
                        break;
                    case "A_Report":
                        e.target.title = language_("Report/block users based on selected mode","根据所选模式举报/屏蔽用户","選択したモードに基づいてユーザーを報告/ブロックする")
                        break;
                    case "report_":
                        e.target.id == "ReportSET"&&Script_ISrun?e.target.title=language_("Click to toggle Report or Block","切换行为:举报/屏蔽","トグル動作:報告/ブロック "):shion_p.innerText= ""
                        break;
                }
            }
        }
        speech_Item_p2.onblur = ()=>{
            let x=speech_Item_p2.innerText
            typeof parseInt(x)=="number"&&x!=""&&!isNaN(parseInt(x))?Time=Math.abs(parseInt(x))*1000:Time= Time
            localStorage.setItem("Time",Time)
            speech_Item_p2.innerText=Time/1000
        }
        gauging_01.onblur = ()=>{
            let x=gauging_01.innerText
            let xx=parseInt(x)
            typeof xx=='number'&&x!=""&&!isNaN(xx)&&Math.abs(xx)>10?Key_l=Math.abs(xx):Key_l= Key_l
            gauging_01.innerText=Key_l
            localStorage.setItem("Key_l",Key_l)
        }
        gauging_11.onblur = ()=>{
            let x=gauging_11.innerText
            let xx=parseInt(x)
            typeof xx=='number'&&x!=""&&!isNaN(xx)&&Math.abs(xx)>1?BBQ=Math.abs(xx):BBQ= BBQ
            gauging_11.innerText=BBQ
            localStorage.setItem("BBQ",BBQ)
        }
        //===================================================filter================================================================================
        Yagoo = new MutationObserver((Guestbook) => {
            Guestbook.forEach(function (MessageList) {
                MessageList.addedNodes.forEach(function (node,Timer) {
                    if (node.nodeName!="YT-LIVE-CHAT-TEXT-MESSAGE-RENDERER"||node.nodeName=="DIV")return;
                    const Messages_EL = node.querySelector("#message");
                    const Tname = node.querySelector("#author-name");
                    const may = node.querySelector("#chip-badges").children.length;
                    if (!Tname||!Messages_EL||may) return;
                    let Tname_T = Tname.innerText
                    const Cdk = Messages_EL.innerText.replace(re, "")
                    if(Cdk.length < Key_l){Ch_m += 1;return}
                    if (node.querySelector("#card") || node.querySelector(".member")) return;
                    let Key_On = false,Peko = false
                    wait = (Math.floor(Math.random() * 3100)+100)
                    let get_time =new Date().getSeconds()
                    let EN_off=/^[a-zA-Z0-9]+$/g
                    if (EN_off.test(Cdk)) return
                    Keylist_trun.length&&Keylist_trun.some((item)=>{
                        Key_On = new RegExp(item).test(Cdk)
                        return Key_On
                    })
                    Peko = Anemati.includes(Tname_T)
                    let cdk = GetKey(Cdk)
                    let zoo = document.createElement("span");
                    zoo.id = "ZOO"
                    if(Ame){zoo.innerHTML = Zoo();
                            Messages_EL.style.display="none"
                           }
                    Messages_EL.before(zoo)
                    Node_List.push({node:node,name:Tname_T,index:Node_List_index,Isblock:false,Isreport:false,Isspam:false,Message:Messages_EL.innerText})
                    if(!Key_On)Keylist_trun=AddKey_List(cdk,Keylist_trun)
                    if (Key_On) {
                        Report(node,cdk,key_i(cdk),Timer,Node_List_index)
                        if (TTK)autocall(wait,Time,false)
                    } else if (Peko) {
                        Report(node,cdk,key_i(cdk),Timer,Node_List_index)
                    } else {
                        let a=Node_List.length-1,b=Node_List.length-1-BBQ,Iscar=0
                        for(let i=a,c=b<0?0:b;i>=c;i--){
                            if(Node_List[i].name==Tname_T) Iscar++
                        }
                        if (Iscar>=BBQ&&Ch_m<=BBQ) {
                            Anemati.push(Tname_T)
                            Peko = true
                            pekoname(Tname_T,Cdk,Timer,Node_List_index)
                            Report(node,cdk,key_i(cdk),Timer,Node_List_index)
                        }else{
                            AddItems(node,Tname_T,Ch_m,get_time,Timer,Node_List_index)
                        }
                    }
                    Ch_m=0;Node_List_index++
                    counter.innerText = Node_List_index
                });
            });
        });
        Yagoo.observe(Itemslist, {
            childList: true,
        });
        end=function end() {
            Yagoo.disconnect()
            Yagoo=null;
            imgset = null;
            AddItems = null;
            Report = null;
            pekoname = null;
            New_Chat.onmouseover = null;
            New_Chat.onclick = null;
            Auto_mes_L.onclick = null;
            Auto_mes.onmouseleave = null;
            Auto_mes_O.onmouseover = null;
            Auto_mes_O.onclick = null;
            Auto_mes_R.onclick = null;
            Report_key_mes.onclick = null;
            Report_SET_0_Input.onclick = null;
            Report_SET_2_p.onclick = null;
            Settinglist.onclick = null;
            Add_Button.onclick = null;
            Add_Input_Key.onfocus = null;
            Re.onclick = null;
            Del_Button.onclick = null;
            Auto_mes_O_P.onclick= null;
            gauging_01.onblur = null;
            gauging_11.onblur = null;
            Important_Frame.remove()
            Re.remove()
            counter.remove()
            Report_l.remove()
            Auto_mes_O_P.remove()
            rami_1.remove()
            rami_2.remove()
            rami_T.remove()
        }
    }
    //end//
    let sb = document.getElementById("send-button")
    let Set_off=document.getElementById("Set_off")
    let ISblock=document.getElementById("ISblock")
    let ISreplace=document.getElementById("ISreplace")
    let BlockLogs=document.querySelector("#Block_Logs")
    let LogGet=document.querySelector("#Log_Get")
    let LogShow=document.querySelector("#Log_Show")
    let Dump = document.querySelector("#Dump")
    let Sort = document.querySelector("#Sort")
    Sort.style.display = "none"
    Kirara=ISblock.checked
    Ame = ISreplace.checked
    LogShow.disabled=!LogGet.checked
    let TOPdiv=document.getElementById("TOPdiv")
    let button = new MutationObserver((node) => {
        let DT = document.getElementById("TTi")
        color == "#4b4b4b" ?DT.style.color ="#ffffffa8":DT.style.color ="#0000006e"
        if (!node[0].target.getAttributeNode("countdown-active")){
            DT.style.color =""
            DT.innerText = "Ready(slow mode)"
            Interval=null;outtime=1;
        }else{
            DT.innerText = "Waiting(slow mode)";
            window.clearInterval(Interval);
        }
    });
    sb&&button.observe(sb,{attributes: true});
    let Report_Menu_Fram,Dialogs_Confirm_Fram,Main_Menu_Fram,MenuOperationing=false
    function report_set() {
        let body_ = document.querySelector("body")
        let Mumei =document.querySelector("yt-live-chat-app")
        let Menu_Set = new MutationObserver((node) => {
            for (let item of node){
                for (let op of item.addedNodes){
                    switch (op?.children[0]?.nodeName)
                    {
                        case "YT-REPORT-FORM-MODAL-RENDERER":
                            Report_Menu.disconnect()
                            Report_Menu.observe(op,{attributeFilter:[ "style"],})
                            Report_Menu_report=op.querySelector("#submit-button")
                            Report_Menu_Item=op.querySelector(".radio.style-scope.yt-options-renderer")
                            Report_Menu_Fram = op
                            Report_Menu_Fram.style.visibility = "hidden"
                            break;
                        case "YT-CONFIRM-DIALOG-RENDERER":
                            Dialogs.disconnect()
                            Dialogs.observe(op,{attributeFilter:[ "style"],});
                            Dialogs_Confirm=op.querySelector("#confirm-button")
                            Dialogs_Confirm_Fram = op
                            Dialogs_Confirm_Fram.style.visibility = "hidden"
                            break;
                        case "DIV":
                            if(op?.children[0].children[0].nodeName!="YTD-MENU-POPUP-RENDERER") return
                            Main_Menu.disconnect()
                            Main_Menu.observe(op,{attributeFilter:[ "style"],});
                            Main_Menu_Box = op.querySelector("#items").children
                            Main_Menu_Fram = op
                            Main_Menu_Fram.style.visibility = "hidden"
                            switch (Main_Menu_Box.length)
                            {
                                case 2:
                                    Account_Type="Normal"
                                    Isnormal=true
                                    break;
                                case 5:
                                    Account_Type="Moderator"
                                    IsMod=true
                                    break;
                                case 7:
                                    Account_Type="Owner"
                                    IsOwner=true
                                    break;
                            }
                            break;
                    }
                }
            }
        });
        let Blocking=false
        Menu_Set.observe(Mumei, {
            childList: true,
        });
        let Menu_black = new MutationObserver((node) => {
            for (let item of node){
                for (let op of item.addedNodes){
                    if (op.nodeName=="TP-YT-IRON-OVERLAY-BACKDROP")op.style.visibility = "hidden"
                }
            }
        });
        Menu_black.observe(body_, {childList: true,});
        let Main_Menu = new MutationObserver((E) => {
            if(ISclean){
                ProcessStarts=true
                let Main_Menu_Click,BlockText
                let BoxLength=Main_Menu_Box.length
                switch (Account_Type)
                {
                    case "Normal":
                        Main_Menu_Click=Main_Menu_Box[1]
                        break;
                    case "Moderator":
                        Node_List[Achan].URL=document.querySelector("ytd-menu-navigation-item-renderer").children[0].href
                        Main_Menu_Click=BoxLength==5?Main_Menu_Box[4]:Main_Menu_Box[3]
                }
                BlockText=Main_Menu_Click.querySelector("yt-formatted-string").childNodes[0].nodeValue
                if(Block_==null)Block_=BlockText
                Node_List[Achan].Isblock = (Block_==BlockText);
                Control_Mian=true;Control_Menu=true;Control_Dialogs=true;
                Main_Menu_Click.children[0].children[0].click()
                ISclean=false
                return
            }
            if (Main_Menu_Fram.style.display=="none"||Achan==null||!Control_Mian)return
            Control_Mian=false;Control_Menu=true;ProcessStarts=true;
            Node_List[Achan].Isspam = true
            Mod_dell=null
            if (!Script_Running&&!ISmanual&&!Mod_Runing&&!Script_ISrun)return
            let Main_Menu_Click
            let BoxLength=Main_Menu_Box.length
            switch (Account_Type)
            {
                case "Normal":
                    if(!Mode||ClickBlock){
                        Blocking=true
                        let Blocked = Node_List.some((item)=>{
                            return (Node_List[Achan].name == item.name&&item.Isblock)
                        })
                        if(Blocked){
                            Node_List[Achan].node.remove();
                            Node_List[Achan].Isblock = true;
                            ///
                            Achan=null
                            Automatic.shift()
                            Script_Running&&setTimeout(()=>{automated()},1000)
                            return
                        }
                        Main_Menu_Click=Main_Menu_Box[1]
                        let BlockText=Main_Menu_Click.querySelector("yt-formatted-string").childNodes[0].nodeValue
                        if(Block_==null)Block_=BlockText
                        Node_List[Achan].Isblock = true;
                    }else{
                        Main_Menu_Click=Main_Menu_Box[0]
                        Node_List[Achan].Isreport = true
                    }
                    break;
                case "Moderator":
                    Node_List[Achan].URL=document.querySelector("ytd-menu-navigation-item-renderer").children[0].href
                    if(Mod_Runing){
                        if(BoxLength == 5 ){
                            Main_Menu_Click= Main_Menu_Box[2]
                            if(!ClickBlock)Mes(language_("Comment deleted","已删除评论","コメントが削除されました "))
                            Kirara&&ISmanual&&setTimeout(()=>{
                                Node_List[Achan].node.querySelector("#button.yt-icon-button").click()
                                ClickBlock=true;Control_Mian=true;ProcessStarts=false
                            },1000)
                            Node_List[Achan].Isspam=true;
                            Control_Mian=true
                            if(!Kirara)Achan=null
                        }else if(BoxLength == 4){
                            Main_Menu_Click= Main_Menu_Box[3]
                            Mes(language_("User has been blocked","用户已屏蔽","ユーザーがブロックされました"))
                            Node_List[Achan].Isblock = true;
                            Achan=null;ProcessStarts=false;
                        }
                    }else if((Script_ISrun&&!Mode)||ClickBlock){
                        Main_Menu_Click=BoxLength==5?Main_Menu_Box[4]:Main_Menu_Box[3]
                        let Blocked = Node_List.some((item)=>{
                            return (Node_List[Achan].name == item.name&&item.Isblock)
                        })
                        if(Blocked){
                            Node_List[Achan].node.remove();
                            Node_List[Achan].Isblock = true;
                            Automatic.shift()
                            Achan=null;ProcessStarts=false
                            Script_Running&&setTimeout(()=>{automated()},1000)
                            return
                        }
                        BlockText=Main_Menu_Click.querySelector("yt-formatted-string").childNodes[0].nodeValue
                        if(Block_==null)Block_=BlockText
                        Mes(language_("User has been blocked","用户已屏蔽","ユーザーがブロックされました"))
                        Main_Menu_Click.children[0].children[0].click()
                        Node_List[Achan].Isblock = true;
                        Node_List[Achan].node.remove()
                        Achan=null;ClickBlock = false;ProcessStarts=false
                        Automatic.shift()
                        Script_Running&&setTimeout(()=>{automated()},1000)
                        return
                    }else if(Script_ISrun&&Mode){
                        Main_Menu_Click=Main_Menu_Box[1]
                        Node_List[Achan].Isreport = true
                    }
                    break;
                case "Owner":
                    if(Mod_Runing){
                        if(BoxLength == 7 ){
                            Main_Menu_Click= Main_Menu_Box[3]
                            Mes(language_("Comment deleted","已删除评论","コメントが削除されました "))
                            Control_Mian=true
                        }else{
                            return
                        }
                    }
            }
            Main_Menu_Click.children[0].children[0].click()
        });
        let Dialogs = new MutationObserver((E) => {
            if(clean){
                Dialogs_Confirm.children[0].children[0].click();
                clean=false;Control_Menu=true;ProcessStarts=false
                return
            }
            if (Dialogs_Confirm_Fram.style.display=="none"||Achan==null)return
            Control_Menu=true
            Dialogs_Confirm.children[0].children[0].click();
            if(!Mode||Dialogs_Confirm.parentNode.children[0].getAttribute("hidden")==null){
                Mes(language_("User has been blocked","用户已屏蔽","ユーザーがブロックされました"))
            }else{
                Mes(language_("Comment has been reported","已举报评论","コメントが報告されました"))
            }
            if (Kirara&&Mode&&!ClickBlock){
                Control_Mian=true;
                ClickBlock = true;
                Node_List[Achan].node.querySelector("#button.yt-icon-button").click()
                return
            }
            if(Blocking){
                ClickBlock = false;
                Blocking = false;
            }
            if(!ClickBlock){
                Node_List[Achan].node.remove()
                Achan=null;
                log_2++;
                nethe++;
                log1.innerText = nethe
            }
            Control_Mian=true;ProcessStarts=false
            error=null;
            Automatic.shift()
            Script_Running&&setTimeout(()=>{automated()},1000)
        });
        let Report_Menu = new MutationObserver((E) => {
            if (Report_Menu_Fram.style.display=="none"||Achan==null||!Control_Menu)return
            Control_Menu=false; Control_Mian=true;Control_Dialogs=true
            Report_Menu_Fram.style.visibility = "hidden"
            Report_Menu_Item.click()
            Report_Menu_Item.setAttribute('class', 'radio style-scope yt-options-renderer iron-selected')
            Report_Menu_Item.setAttribute('aria-checked', 'true')
            Report_Menu_Item.setAttribute('aria-selected', 'true')
            Report_Menu_Item.setAttribute('checked', '')
            Report_Menu_Item.setAttribute('active', '')
            Report_Menu_Item.setAttribute('focused', '')
            if(Mode)Node_List[Achan].node.querySelector("#message").style.color=color_ames+"30"
            Report_Menu_report.click();
        });
    }
    function autocall(wait,limit){
        if (!Interval&&outtime){
            outtime=0
            const fram = document.querySelector("#mes_box").children
            let mes_i=Math.floor(Math.random()*fram.length)
            let none2 = fram[mes_i]?.innerHTML||"kawaii"
            Bchan=limit
            setTimeout(function(){
                if (!Bchan)Bchan = Ch_m<spam
                Bchan&&call(none2)
            },wait)
        }
    }
    function call(none){
        let iv=document.querySelector("DIV#input")
        if (!iv) return
        iv.parentNode.setAttribute('focused', '')
        let ie= new InputEvent("input")
        iv.innerHTML= none
        iv.dispatchEvent(ie);
        document.querySelector("yt-button-renderer.yt-live-chat-message-input-renderer").click()
        iv.innerHTML = null
        let DT = document.getElementById("TTi")
        color == "#4b4b4b" ?DT.style.color ="#ffffffa8":DT.style.color ="#0000006e"
        let DT_time=Time/1000
        DT.innerText = "Waiting"
        Interval=setInterval(()=>{
            if (DT_time===0){
                DT.innerText="Ready"
                window.clearInterval(Interval);
                Interval=null
                outtime=1
            }else{
                DT_time -=1
                DT.innerText = "Waiting\("+DT_time+"\)Sec"
            }
        },1000)
    }
    function localItem(){
        const load_mes = document.querySelector("#mes_box").children
        let item_j=""
        for (let item of load_mes){
            let t=item.innerHTML
            item_j?item_j=item_j +"|" + t :item_j=item_j + t
        }
        localStorage.setItem("IMGitem",item_j)
    }
    function img(){
        const fram = document.querySelector("#img_box")
        if (fram.children.length)return
        const iron = document.querySelector("iron-pages#pickers")
        const img = iron.querySelectorAll("div#emoji")
        let x
        img.length==9?x=1:x=2
        for (let i= 1,l=img.length;i<l;i++){
            if (i == x)continue
            ((t)=>{
                let img_new=img[t].cloneNode(true)
                setTimeout(()=>{fram.appendChild(img_new)},t*1000)
            })(i)
        }
    }
    function iron_load(){
        let iron_box= document.querySelector("yt-live-chat-icon-toggle-button-renderer#emoji.yt-live-chat-message-input-renderer")
        if(!iron_box)return
        iron_box = iron_box.querySelector("yt-interaction#interaction.yt-icon-button")
        iron_box.click()
        iron_box.click()
        setTimeout(()=>{img()},3000)
    }
    function DellArray(V,Array){
        for (let i= Array.length-1;i>=0;i--){
            if(Array[i]==V){
                Array.splice(i, 1)
            }
        }
    }
    window.onbeforeunload = function(){
        let key__=Keylist_Re.join("\n").replace(/(\.\*)/g, "")
        navigator.clipboard.writeText(key__).then(() => {})
    }
    function AddKey_List(cdk,arr){
        arr.push(cdk)
        return [...new Set(arr.filter((item)=>{return item}))]
    }
    function GetKey(en) {
        let items=Array.from(en,(x,i)=>i===0?x:".*"+x).join("")
        return items
    }
    function key_i(cdk){///????????????
        for (let i=0,l=Keylist_trun.length;i<l;i++) {
            let reg_kkey = new RegExp(Keylist_trun[i]);
            if (reg_kkey.test(cdk)) {return i}
        }
    }
    let Report_key_mes= document.querySelector("#key_mes")
    let Report_SET_2_p=document.querySelector("#dad")
    let Coco=document.getElementById("antetype_mes");
    function automated(item,index){
        clearTimeout(korone);korone=null
        if (item){
            Automatic.unshift({node:item,index:index})
            !ProcessStarts&&automated()
        }else{
            if(Automatic.length){
                Control_Mian=true;Control_Menu=true;Control_Dialogs=true
                Achan = Automatic[0].index;error = Achan;
                Report_key_mes.scrollTop=Automatic[0].node.parentNode.parentNode.parentNode.offsetTop-175
                Automatic[0].node.querySelector("#button.yt-icon-button").click()
                Automatic[0].node.parentNode.parentNode.style.background="#63aaf7"
                Automatic[0].node.parentNode.parentNode.style.display = ""
                if(Script_Running){
                    korone=setTimeout(()=>{
                        Automatic[0].node.remove();
                        Automatic.splice(0,1)
                        automated()
                    },5000)
                }
            }else{
                Script_Running=false
                Report_SET_2_p.innerText=language_("|Completed(","|完成(","|Completed(")+log_2+language_(")Again",")重复",")Again")
            }
        }
    }
    const pro=document.getElementById("Pro")
    const pro_mes=document.getElementById("PRO_1")
    const MainWindow = document.getElementById("MainWindow");
    const point=document.getElementById("state")
    let wi=MainWindow.clientWidth
    pro.style.width=wi+"px";
    pro.setAttribute('class', 'pro');
    pro.style.visibility = "hidden";
    function Mes(mes){
        pro.style.visibility = "visible"
        pro_mes.innerHTML = mes
        if(prpr){
            clearTimeout(prpr)
            prpr=null;
        }
        prpr=setTimeout(()=>{
            pro.style.visibility = "hidden";
            prpr=null;
        },700)
        checked_();
    }
    let Userurl,yooooo=[]
    document.querySelector("#Classification").onchange=(e)=>{
        let Fragment = document.createDocumentFragment(),URL_Textarea
        switch (document.querySelector("#Classification").value)
        {
            case "Null":
                BlockLogs.innerHTML=null;
                Log()
                break;
            case "report_ed":
                BlockLogs.innerHTML=null;
                Node_Log_List.forEach((item,i)=>{
                    if(!item.Isreport)return;
                    let div = Coco.cloneNode(true);
                    let index=Node_Log_List[i].index
                    div.querySelector("#antetype").id= index
                    let logn=div.querySelector("#Log_Name")
                    logn.innerText = item.name;
                    div.querySelector("#Log_Comment").innerText = item.Message
                    let input =div.querySelector("#Unblock")
                    input.id="IS__Block"
                    if(item.Isblock){
                        div.querySelector("#IS__Block").setAttribute('checked', '');
                        logn.style.color="#fff";
                    }
                    div.style.display = "inline-flex";
                    Fragment.appendChild(div);
                })
                BlockLogs.appendChild(Fragment)
                break;
            case "block_ed":
                BlockLogs.innerHTML=null;
                Node_Log_List.forEach((item,i)=>{
                    if(!item.Isblock)return;
                    let div = Coco.cloneNode(true);
                    let index=Node_Log_List[i].index
                    div.querySelector("#antetype").id= index
                    let logn=div.querySelector("#Log_Name")
                    logn.innerText = item.name;
                    div.querySelector("#Log_Comment").innerText = item.Message
                    let input =div.querySelector("#Unblock")
                    input.id="IS__Block"
                    if(item.Isblock){
                        div.querySelector("#IS__Block").setAttribute('checked', '');
                        logn.style.color="#fff";
                    }
                    div.style.display = "inline-flex";
                    Fragment.appendChild(div);
                })
                BlockLogs.appendChild(Fragment)
                break;
            case "URL_":
                BlockLogs.innerHTML=null;
                URL_Textarea = document.createElement("textarea");
                yooooo=[]
                for (let i=0,l=Node_Log_List.length;i<l;i++){
                    if(Node_Log_List[i].URL&&(Node_Log_List[i].Isblock||Node_Log_List[i].Isreport))yooooo.push(Node_Log_List[i].URL);
                }
                yooooo=[...new Set(yooooo)]
                URL_Textarea.value = yooooo.join("\n")
                BlockLogs.appendChild(URL_Textarea)
        }
    }
    document.querySelector("#Category_sort").onchange=(e)=>{
        BlockLogs.style.height = "414px";
        sort(true,document.querySelector("#Category_sort").value,Node_Log_List);
        BlockLogs.innerHTML=null;
        Log();
    }
    function Log(){
        let Fragment = document.createDocumentFragment()
        Node_Log_List.forEach((item,i)=>{
            let div = Coco.cloneNode(true);
            let index=Node_Log_List[i].index
            div.querySelector("#antetype").id= index
            let logn=div.querySelector("#Log_Name")
            logn.innerText = item.name;
            div.querySelector("#Log_Comment").innerText = item.Message
            let input =div.querySelector("#Unblock")
            input.id="IS__Block"
            if(item.Isblock){
                div.querySelector("#IS__Block").setAttribute('checked', '');
                logn.style.color="#fff";
            }
            div.style.display = "inline-flex";
            Fragment.appendChild(div);
        })
        BlockLogs.appendChild(Fragment)
    }
    TOPdiv.onclick=(e)=>{
        let Fragment,logn,Shake,he,mode,of,GTA
        switch (e.target.id)
        {
            case "Set_off":
                TOPdiv.style.visibility="hidden";
                BlockLogs.innerHTML=null
                LogShow.checked =false
                Mode=Kirara?1:old_Mode
                mode=document.getElementById("ReportSET")
                Sort.style.display = "none"
                of = Mode?language_("Report","举报","報告"):language_("Block","屏蔽","ブロック")
                if(document.querySelector("#Auto_Report").checked)mode.innerText= language_("Mode:(","模式:(","モード:(")+of+")"
                break;
            case "ISblock":
                Isblock = ISblock.checked?"checked":" "
                Kirara=ISblock.checked
                Mode=Kirara?1:0
                localStorage.setItem("IsBlock",Isblock)
                break;
            case "ISreplace":
                Isreplace = ISreplace.checked?"checked":" "
                Ame=ISreplace.checked
                localStorage.setItem("Isreplace",Isreplace)
                break;
            case "Log_Get":
                IsLogGet = LogGet.checked?"checked":" "
                Ina=LogGet.checked
                localStorage.setItem("IsLogGet",IsLogGet)
                LogShow.disabled=!Ina
                if(Ina){
                    Node_Log_List = Node_List.filter((item)=>{
                        return item.Isspam
                    }) }else{
                        Node_Log_List=[]
                        BlockLogs.innerHTML=null
                        LogShow.checked=false
                    }
                break;
            case "Log_Show":
                Node_Log_List = Node_List.filter((item)=>{
                    return item.Isspam
                })
                Gura =LogShow.checked
                Gura?Sort.style.display = "":Sort.style.display = "none"
                if(!Gura){
                    BlockLogs.innerHTML=null
                    return
                }
                BlockLogs.style.height = "414px"
                ISmanual=0
                Log()
                break;
            case "IS__Block":
                Achan=Number(e.target.parentNode.id)
                Mode=0;ISclean=true;GTA=Node_List[Achan]
                if(e.target.checked)clean=true
                Dump.appendChild(GTA.node)
                GTA.node.querySelector("#button.yt-icon-button").click();
                break;
            case "Log_Name":
                if(!IsMod&&!IsOwner)return
                navigator.clipboard.writeText(Node_List[e.target.nextSibling.id].URL).then(() => {})
                alert(language_("Copied","已复制","コピーした"))
        }
    }
    function sort(Sort,type,arr){
        arr.sort((a,b)=>{
            let x, y
            switch (type)
            {
                case "name":
                    x = a.name.length
                    y = b.name.length
                    break
                case "Mes_length":
                    x = a.Message.length
                    y = b.Message.length
                    break
                case "name_abc":
                    x = a.name.toLowerCase()
                    y = b.name.toLowerCase()
            }
            if (x < y) {
                if (Sort){
                    return -1;
                }else{
                    return 1;
                }
            }
            if (x > y) {
                if (Sort){
                    return 1;
                }else{
                    return -1;
                }
            }
            return 0;
        })
    }
    ///////////////////////////////////////////////////////
    function Set_(){
        let wi=window.innerWidth
        let hi=window.innerHeight-169;
        TOPdiv.style.width=wi+"px";
        TOPdiv.style.height=hi+"px";
        TOPdiv.style.visibility = "visible"
    }
    function checked_(){
        const newchat = document.getElementById("new_div_chat");
        let nl=newchat.children
        for (let i=0;i<nl.length;i++){
            let mes=nl[i].querySelector("yt-live-chat-text-message-renderer")
            if(!mes){
                nl[i].remove()
                i--
            }else{
                break
            }
        }

    }
    function Zoo(){
        let zoo=[]
        zoo[0]='にゃん';zoo[1]='モグ';zoo[2]='ワン';zoo[3]='パチ';zoo[4]='ピカ';zoo[5]='ガオ';
        let i=Math.floor(Math.random()*6)
        let b=zoo[i]+zoo[i]
        for(let n=0;n<=Math.floor(Math.random()*2);n++){
            b+=zoo[i]
        }
        return b
    }
    /////////////point///////////////////
    let point_list = [
        language_("Arrow keys→: report/block/delete","方向键→:举报/拉黑/删除","矢印キー→:レポート/ブロック/削除"),
        language_("Arrow keys←: Skip comment","方向键←:跳过评论","矢印キー←:コメントをスキップ"),
        language_("Translation function requires [sc translation] plugin","翻译功能需要[sc翻译]插件支持","翻訳機能には[SC Translation]が必要です"),
        language_("Regular users/members can't get the channel URL","一般用户/会员无法获取频道网址","通常のユーザー/メンバーはチャンネルのURLを取得できません"),
        language_("Can be unblocked in detailed settings","可以详细设置里取消屏蔽","詳細設定でブロックを解除できます"),
        language_("Machine translated","机翻的文字","機械翻訳されたテキスト"),
        language_("Member comments are not ","不会抓取会员评论","メンバーのコメントをフィルタリングしません"),
        language_("Don't keep pressing the arrow key","不要一直按着方向键","矢印キーを押し続けないでください"),
        language_("Check if the account is spam after the end","结束后检查账号是不是spam","live終了後、アカウントが本当にスパムかを確認してね"),
    ]
    function Point(){
        let nc = point_list.length-1
        let ne= nc<0?0:nc
        point.innerText = point_list[Math.floor(Math.random()*ne)]
    }
    let poi =setInterval(()=>{
        Point()
    },20000)
    /////////////point///////////////////
    let Deleting,Delet_mes
    function Queue(mes,index){
        if(mes){
            Del_List.push({node:mes,index:index})
            !Deleting&&Queue()
        }else{
            Delet_mes = Del_List.pop()
            Achan = Delet_mes.index
            Delet_mes.node.querySelector("#button.yt-icon-button").click()
            Deleting = setTimeout(()=>{
                Del_List.length?Queue():Deleting=null
            },Delete_interval)
        }
    }

    const nullll = GM_registerMenuCommand("┏━━━━━━━━━━━━━━━━━━━━┓", () => {
    });
    const nullll1 = GM_registerMenuCommand("┣━━━━━━━━━━━━━━━━━━━━┫", () => {
    });
    const nullll11 = GM_registerMenuCommand("┗━━━━━━━━━━━━━━━━━━━━┛", () => {
    });
    const Start = GM_registerMenuCommand(language_("On/Off:Click to restart","开/关:重启脚本","On/Off:Click to restart"), () => {
        ONOff?ONOff=false:ONOff=true
        if(ONOff){
            launch()
        }else{
            end&&end()
            end=null
        }
    });
    report_set()
})();