// ==UserScript==
// @name youtube live chat script: report comment&&block user
// @namespace null
// @version 2.0.0
// @description dellll
// @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,sc
const SET = GM_registerMenuCommand(language_("Detailed Settings&Log","详细设置&Log","詳細設定&Log"), () => {
Set_()
});
let Anemati=[],Node_List=[],Node_Log_List = [],Del_List = [],KeyItemList = []
let ONOff=true,Achan=null,Mod_dell=null
let Mod_Runing=0,Ch_m = 0,Node_List_index=0,Delete_interval = 1500,BC= 0 ,Pageleng=0,Spam=0,Normal=0,Untreated=0,doc = Number(localStorage.getItem("doc"))||5,AutoReport=false
let prpr,Kirara,Ame,Gura,color,Yagoo,Itemslist,color_ames,end,aki,korone
let Key_l = Number(localStorage.getItem("Key_l"))||16,BBQ = Number(localStorage.getItem("BBQ"))||3
let Isblock=localStorage.getItem("IsBlock"),Isreplace=localStorage.getItem("Isreplace")||"checked"
let Main_Menu_Box, Dialogs_Confirm ,Report_Menu_report,Report_Menu_Item,index_dell,WTF_1,WTF_2,YMD,YMD_Type,Deleting,Delet_mes,X,AutoR
let re = /[\u1F601-\u1F64F]|[\u0E00-\u0E7F]|<img.*src.*alt.*>|\[.{1,5}\]|[\[\]\-\_\,\!\|\.\~\`\(\)\#\$\%\^\&\*\+\-\{\}\:\;\"\<\>\@\?\\\/\s\=]|\’|\'/g
let PageMode = doc ,pages=doc,Page=0,PageN = 1
//css
GM_addStyle(".mes_log_class{font-size:12px;line-height: 25px;text-indent:25px;color: #aaaaaa;}")
GM_addStyle(".item_class{text-indent:15px;display:inline-block;width:100%}")
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("#new_div_chat{overflow-y:auto;height:175px;overflow:scroll}")
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{font-size: 14px;line-height: 25px;text-indent:25px;color: #aaaaaa;}")
GM_addStyle("#Set_off{font-size: 14px;line-height: 21px;text-align:center}")
GM_addStyle(".shion_P{display:inline-block;text-indent: 0px;}")
GM_addStyle("#Y{user-select:none;cursor:pointer}")
function css_white(){
color = "rgba(0, 0, 0, 0.23)"
GM_addStyle(".set_list{width:50%;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;user-select: none")
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}")//
}
function css_black(){
color = "#4b4b4b"
GM_addStyle(".set_list{width:50%;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;user-select: none")
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}")//
}
/////////////////////////////////////////////////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() {
let Y = document.createElement("div");
Y.innerHTML =' <span id = "Y" style="height: 24px;width: 24px;background: #0ff0;">◺</span> '
Y.title = language_("Turn on detailed settings and log(","打开详细设置和log","詳細設定とログを開く")
Y.onclick = ()=>{
Set_()
}
const New_Chat_Frame = document.querySelector("#contents.yt-live-chat-renderer");
if (New_Chat_Frame){
switch (window.getComputedStyle(New_Chat_Frame, null)?.getPropertyValue('border-color'))
{
case "rgb(255, 255, 255)":
css_black()
color_ames="#ffffff"
WTF_1 = "#303030"
WTF_2 = "#202020"
break;
case "rgb(3, 3, 3)":
css_white()
color_ames="#000000"
WTF_1 = "#d6d6d6"
WTF_2 = "#eeeeee"
break;
}
}
Itemslist = document.querySelector("#items.yt-live-chat-item-list-renderer");
if (!Itemslist) return;
const Important_Frame = document.createElement("div");
Important_Frame.id = "MainWindow";
Important_Frame.setAttribute("class","MainWindow_css");
const shion = document.createElement("div");
const shion_P1 = document.createElement("div");
const shion_P2 = 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");
const GetNewMes = document.createElement("input")
const DellMes = document.createElement("input")
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"
shion_P1.setAttribute("class","shion_P")
shion_P1.style.width = "60%";
shion_P2.setAttribute("class","shion_P")
Settinglist.id = "settinglist";
SettingItem.id = "settingitem";
GetNewMes.type = "button"
GetNewMes.style.visibility = "hidden"
DellMes.type = "button"
DellMes.style.visibility = "hidden"
DellMes.value = language_("Report","举报","報告")
DellMes.title = language_("arrow key →","方向键 →","矢印キー →");
GetNewMes.title = language_("arrow key ←","方向键 ←","矢印キー ←");
shion_P2.appendChild(GetNewMes);
shion_P2.appendChild(DellMes);
for (let i=0;i<2;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;
}
Settinglist.appendChild(set_List);
set_List.appendChild(Title);
SettingItem.appendChild(set_Item_List);
}
shion_P1.appendChild(shion_p);
shion.appendChild(shion_P1);
shion.appendChild(shion_P2);
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")
AutoR = document.createElement("div");
let my = self?.querySelector("#chat-badges")
AutoR.style.cursor = "pointer"
AutoR.style.fontSize="16px";
AutoR.innerText = "♲"
AutoR.style.userSelect="none"
AutoR.title = language_("Enable/disable automatic reporting","开启/关闭自动举报功能","自動レポートをオン/オフにする");
AutoR.onclick = (e)=>{
AutoReport=AutoReport?false:true
AutoR.style.color=AutoReport?"aqua":""
}
const Inputs = document.getElementById("Input_Key_Item");
const gauging_Item = document.getElementById("gauging_Item");
let Null_div = document.createElement("div");
Null_div.style.display = "none";
Inputs.style.display="none"
gauging_Item.style.display=""
const TItle_1= document.getElementById("Input_Key_List");
const TItle_2= document.getElementById("gauging");
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("div");
const gauging_dell = document.createElement("input");
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.style.display = "inline-block";
gauging_12.style.visibility = "hidden"
gauging_dell.setAttribute("type","checkbox");
gauging_dell.id = "ALL_Del"
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_12.appendChild(gauging_dell);
gauging_Item.appendChild(gauging_0);
gauging_Item.appendChild(gauging_1);
gauging_Item.appendChild(gauging_12);
MainWindow.appendChild(O_Item);
const New_Chat = document.createElement("div");
const Keyword_Frame = document.createElement("div");
const Keyword_Frame_Textarea = document.createElement("textarea");
Keyword_Frame_Textarea.id = "keys"
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_Textarea.style.overflowY="scroll"
Keyword_Frame_Textarea.style.overflowX="scroll"
Keyword_Frame_Textarea.style.whiteSpace="pre"
Keyword_Frame.appendChild(Keyword_Frame_Textarea);
O_Item.appendChild(Keyword_Frame);
O_Item.appendChild(New_Chat);
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 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"
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 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")
rami_1.innerText="MSG:"
kanata_1.appendChild(rami_1)
kanata_1.appendChild(counter)
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"
let IsTaKo = '<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>'
+ '<div style="overflow-y: scroll;overflow-x: hidden;">'
+ '<div style="height: 30px;width: 100%;display: inline-flex">'
+ '<div class="ppts" style="width: 85%;">'
+ '<span>' + language_("Block Users", "屏蔽用户", "ユーザーをブロックする") + '</span>'
+ '</div>'
+ '<div class="ppts" style="width: 15%">'
+ '<input id="ISblock" disabled type="checkbox" ' + Isblock + '>'
+ '</div>'
+ '</div>'
+ '<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%">'
+ '<input id="ISreplace" type="checkbox" ' + Isreplace + '>'
+ '</div>'
+ '</div>'
+ '<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%">'
+ '<input id="Log_Show" type="checkbox">'
+ '</div>'
+ '</div>'
+ '</div>'
+ '<div style="width: 100%;height: 10px;background-color:#f9f9f947">'
+ '</div>'
+ '<div id="antetype_mes" style="display: none;border-bottom: 1px solid #666;border-top-width: 1px; border-left-width: 1px;border-left-style: solid;border-top-style: solid;">'
+ '<div style="display: inline-flex; width: 100%">'
+ '<div id="Log_Name" class="ppts" style="width: 85%;color:#ffffff"> =_________________________________='
+ '</div>'
+ '<div id="antetype" class="ppts" style="width: 15%;display: none" >'
+ '<input id="Unblock" type="checkbox" >'
+ '</div>'
+ '</div>'
+ '<div id = "mes_log" class = "mes_log_class" style="display: none">'
+ '</div>'
+ '</div>'
+ '<div id = "AllLog" style=" border-bottom-width: 0px; width: 100%;height: 25px;background-color:#f9f9f930" >'
+ '<div class="ppts">' + language_("Sort type", "排序:", "ソートタイプ")
+ '<select id="Category_sort">'
+ '<option value="name">' + language_("Name", "名字", "名前")+ '</option>'
+ '<option value="name_abc">' + language_("First letter", "首字母", "頭文字") + '</option>'
+ '<option value="Mes_length">' + language_("Comment Word Count", "评论字数", "コメントの文字数") + '</option>'
+ '<option value="Blocked">' + language_("Blocked", "已屏蔽", "Blocked") + '</option>'
+ '</select>'
+ '</div>'
+ '<div id="Block_Logs" style="overflow-y: scroll;overflow-x: hidden;">'
+ '</div>'
+'<div id = "Options" class="ppts">'
+'<input id="up_" type="button" value="<" >'
+'<input id ="page_" type="text" style=" width:35px" value = "1">'
+'<input id="dow_" type="button" value=">" > '
+'<input id="max_"type="button" value="Max:1">'
+' <input id="Untreated_"type="button" value=' + language_("Untreated", "未处理", "未処理") +' >'
+' <input id ="isco" type="text" style=" width:20px" value = "'+doc+'">/Page'
+'</div>'
+ '</div>'
+ '<div id="Dump" style="display:none">'
+ '</div>'
TOP_div.innerHTML = IsTaKo
bo.appendChild(TOP_div)
document.querySelector("yt-icon-button#overflow").after(Y)
document.querySelector("yt-icon-button#overflow").before(AutoR)
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 Report(mes,cdk,index){
Node_List[index].Isspam=true;
Node_List[index].act = "Report"
KeyItemList.some((item)=>{
let Key_On = new RegExp(item.regexp).test(cdk)
if(Key_On)item.spam=true;
return Key_On;
})
shion_p.innerText=count()
AutoReport&&Queue(mes,index)
}
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_src == name &&i!=index&&Node_List[i].Isspam != true){
let cdk=Node_List[i].Message.trim()
Report(Node_List[i].node,cdk,i)
}
}
}
function Getmes(){
if(BC>299){
for(let i = 299;i>=99;i--){
New_Chat.children[i].remove()
BC--
}
}
for(let i=Node_List.length-1;i>=0;i--){
if (Node_List[i].Isspam===null){
index_dell=i
break
}
}
if (index_dell!=null){
Mod_dell = Node_List[index_dell].node
let Item = document.createElement("div")
Item.id = index_dell
Item.innerText =Node_List[index_dell].Message
Item.setAttribute("class","item_class");
Item.style.fontWeight="bold"
Item.style.backgroundColor=BC%2==0?WTF_1:WTF_2
New_Chat.prepend(Item)
BC++
GetNewMes.value = language_("Skip","跳过","スキップ")
DellMes.style.visibility = "visible"
Reset()
}else{
Mes(language_("No Comment!","没有评论!","コメントなし!"))
GetNewMes.style.visibility = "hidden"
}
}
function Action(){
let cdk=Mod_dell.querySelector("#message").innerText.trim()
KeyItemList.some((item)=>{
let Key_On = new RegExp(item.regexp).test(cdk)
if(Key_On)item.spam=true;
return Key_On;
})
Node_List[index_dell].act = "Report"
let first =New_Chat.firstElementChild
first.style.textDecoration="line-through"
first.style.fontWeight="normal"
first.style.opacity = 0.5
Node_List[index_dell].Isspam = true;
Queue(Mod_dell,index_dell)
Mod_dell=null
index_dell=null
shion_p.innerText=count()
if(Untreated){
Getmes()
}else{
GetNewMes.style.visibility = "hidden"
DellMes.style.visibility = "hidden"
}
}
function skip(){
Mes(language_("Comment skipped","已跳过评论","スキップしました"))
Node_List[index_dell].Isspam = false;
New_Chat.firstElementChild.style.color="green"
New_Chat.firstElementChild.style.fontWeight="normal"
New_Chat.firstElementChild.style.opacity = 0.5
Mod_dell=null
index_dell=null
shion_p.innerText=count()
if(Untreated){
Getmes()
}else{
GetNewMes.style.visibility = "hidden"
DellMes.style.visibility = "hidden"
}
}
function Reset(){
clearTimeout(korone);korone=null
korone=setTimeout(()=>{
if(!Untreated){
GetNewMes.style.visibility = "hidden"
DellMes.style.visibility = "hidden"
}
if(index_dell===null)return;
New_Chat.firstElementChild.remove()
BC--
Mod_dell=null
index_dell=null
Getmes()
},15000)
}
//===================================================onev===============================================================================
let up_ = document.getElementById("up_");
let max_ =document.getElementById("max_");
let page_= document.getElementById("page_");
let dow_ = document.getElementById("dow_");
let isco_ = document.getElementById("isco");
let Untreated_ = document.getElementById("Untreated_");
let Category = document.querySelector("#Category_sort")
dow_.onclick = function(){
if(PageN<Math.ceil(Pageleng/PageMode)) PageN++
if(pages<Pageleng){
Page=Number(Page)+Number(PageMode);
pages=Number(pages)+Number(PageMode)
}
page_.value = PageN
Log_List(YMD,Page,pages)
show_l()
}
up_.onclick = function(){
if(Page-PageMode>=0){
Page=Page-PageMode;
pages=pages-PageMode;
if(PageN>1) PageN--
}
page_.value = PageN
Log_List(YMD,Page,pages)
show_l()
}
isco_.oninput = ()=>{
if(!isco_.value)return
doc = isco_.value<1?5:Number(isco_.value)
isco_.value = doc
localStorage.setItem("doc",doc)
PageMode = doc;pages = doc;Page=0;PageN = 1
page_.value=PageN
Log_List(YMD,Page,pages)
show_l()
}
page_.oninput = ()=>{
pages=doc
if (page_.value<=Math.ceil(Pageleng/PageMode)){
if(page_.value<1)page_.value=1
pages = pages * page_.value
}else{
page_.value = Math.ceil(Pageleng/PageMode)
pages = pages * page_.value
}
Page=pages-PageMode
let max =Math.ceil(Pageleng/PageMode)
Log_List(YMD,Page,pages)
show_l()
}
max_.onclick = function(){
PageMode = doc;pages=doc;Page=0;PageN = 1
let max =Math.ceil(Pageleng/PageMode)
PageN = max
pages = pages * max
Page=pages-PageMode
page_.value = PageN
Log_List(YMD,Page,pages)
show_l()
}
Untreated_.onclick = function(){
Node_Log_List = Node_List.filter((item)=>{
return (item.Isspam === null)
})
if(!Node_Log_List.length)return;
page_.value = 1
Category.selectedIndex=2
Category.disabled = true
Untreated_.value = Untreated+ " " + language_("Untreated", "未处理", "未処理")
Page= 0;pages=doc;PageN = 1
sort(false,"Mes_length",Node_Log_List)
Log_List(Node_Log_List,Page,pages,"mes",false)
show_l()
}
document.addEventListener('keyup', logKey);
shion_p.innerText=count()
function logKey(e) {
switch (e.code)
{
case "ArrowRight":
Mod_dell?Action():Getmes();
break;
case "ArrowLeft":
Mod_dell?skip():Getmes()
}
}
Add_Button.onclick = function addkey() {
let KeyItemList_=""
if (Add_Input_Key.value != ""){
let cdk = Add_Input_Key.value.trim()
KeyItemList.push({regexp:GetKey(cdk),proto:cdk,spam:true})
Add_Input_Key.value = ""
}else if (Keyword_Frame_Textarea.value!=""){
KeyItemList=[]
let Keylist=Keyword_Frame_Textarea.value.trim().split('\n')
DellArray("",Keylist)
Keylist=[...new Set(Keylist)]
Keylist.forEach((cdk)=>{
KeyItemList.push({regexp:GetKey(cdk.trim()),proto:cdk.trim(),spam:true})
})
}
DellArray("",KeyItemList)
let ShowList = KeyItemList.filter((item)=>{
return item.spam
})
for (let i=0,l=ShowList.length;i<l;i++){
KeyItemList_+=(i+1== l)?ShowList[i].proto:ShowList[i].proto+"\n";
}
Keyword_Frame_Textarea.value = KeyItemList_
Del_Button.value = "Delete"
}
Del_Button.onclick = function () {
KeyItemList = []
Del_Button.value = "Delete"
Add_Input_Key.value = ""
Keyword_Frame_Textarea.value = ""
}
GetNewMes.onclick = function () {
Mod_dell?skip():Getmes()
}
DellMes.onclick = function () {
Mod_dell&&Action()
}
Re.onclick = function () {
switch (Re.value)
{
case "Hide":
MainWindow.style.display = "none"
Re.value = "View"
break;
case "View":
MainWindow.style.display = ""
Re.value = "Hide"
}
}
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")
gauging_Item.style.display = "none"
New_Chat.style.display = "none"
Report_key_mes.style.display = "none"
Keyword_Frame.style.display = ""
let KeyItemList_ = ""
let ShowList = KeyItemList.filter((item)=>{
return item.spam
})
for (let i=0,l=ShowList.length;i<l;i++){
KeyItemList_+=(i+1== l)?ShowList[i].proto:ShowList[i].proto+"\n";
}
Keyword_Frame_Textarea.value = KeyItemList_
Del_Button.value = "Delete"
}
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
Inputs.style.display = "none"
New_Chat.style.display = ""
Report_key_mes.style.display = "none"
Keyword_Frame.style.display = "none"
}
break;
}
}
SettingItem.onclick =function(e){
if(e.target.nodeName=="SPAN"){
switch (e.target.parentNode.id)
{
case "Key_l":
gauging_01.focus();
gauging_01.innerText= "";
break;
case "BBQ":
gauging_11.focus();
gauging_11.innerText= "";
}
}
}
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より小さい数値を設定して");
}
}
}
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)
}
const ALL_Del = document.getElementById("ALL_Del");
let del_all
ALL_Del.onclick = ()=>{
del_all = ALL_Del.checked
}
//===================================================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-photo").querySelector("#img");
const Yname = node.querySelector("#author-name")
const may = node.querySelector("#chip-badges").children.length;
if (!Yname||!Messages_EL||may) return;
let Tname_T = Tname.src,Tname_=Yname.innerText
const Cdk = Messages_EL.innerText.trim()
if(Cdk.replace(re, "").length < Key_l){Ch_m += 1;return}
if (node.querySelector("#card") || node.querySelector(".member")) return;
let Key_On = false,Peko = false
let get_time =new Date().getSeconds()
KeyItemList.length&&KeyItemList.some((item)=>{
Key_On = new RegExp(item.regexp).test(Cdk)
if(Key_On)item.spam=true;
return Key_On;
})
Peko = Anemati.includes(Tname_T)
!Key_On&&KeyItemList.push({regexp:GetKey(Cdk),proto:Cdk,spam:false})
Node_List.push({node:node,name:Tname_,name_src:Tname_T,index:Node_List_index,Isblock:false,Isspam:null,Message:Messages_EL.innerText,Time:get_time,interval:Ch_m,act:null})
if(Ame){
let zoo = document.createElement("span");
zoo.id = "ZOO"
zoo.innerHTML = Zoo();
Messages_EL.style.visibility = "hidden"
Messages_EL.before(zoo)
}
if (Peko||Key_On) {
Report(node,Cdk,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_src==Tname_T) Iscar++
}
if (Iscar>=BBQ&&Ch_m<=BBQ) {
Anemati.push(Tname_T)
Peko = true
Report(node,Cdk,Node_List_index)
pekoname(Tname_T,Cdk,Timer,Node_List_index)
}else{
if(Mod_Runing&&del_all){
Node_List[Node_List_index].act = "Delete"
Queue(node,Node_List_index)
}else if(!Mod_dell){
GetNewMes.style.visibility = "visible"
Getmes()
}
}
}
Ch_m=0;Node_List_index++
counter.innerText = Node_List_index
shion_p.innerText=count()
Untreated_.value =Untreated+ " " + language_("Untreated", "未处理", "未処理")
});
});
});
Yagoo.observe(Itemslist, {
childList: true,
});
}
//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 LogShow=document.querySelector("#Log_Show")
let Dump = document.querySelector("#Dump")
let Category = document.querySelector("#Category_sort")
let Report_key_mes= document.querySelector("#key_mes")
let Report_SET_2_p=document.querySelector("#dad")
let Coco=document.getElementById("antetype_mes");
const pro=document.getElementById("Pro")
const pro_mes=document.getElementById("PRO_1")
const MainWindow = document.getElementById("MainWindow");
const point=document.getElementById("state")
const AllLog=document.querySelector("#AllLog")
const max_=document.getElementById("max_")
const Untreated_=document.getElementById("Untreated_")
const shion_p=document.getElementById("tex")
let TOPdiv=document.getElementById("TOPdiv")
let Report_Menu_Fram,Dialogs_Confirm_Fram,Main_Menu_Fram,MenuOperationing=false,wi=MainWindow.clientWidth
AllLog.style.visibility = "hidden"
Kirara=ISblock.checked
Ame = ISreplace.checked
function Menu_Set() {
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(document.querySelector("body"), {childList: true,});
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
break;
case "YT-CONFIRM-DIALOG-RENDERER":
Dialogs.disconnect()
Dialogs.observe(op,{attributeFilter:[ "style"],});
Dialogs_Confirm=op.querySelector("#confirm-button")
Dialogs_Confirm_Fram = op
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
break;
}
}
}
});
Menu_Set.observe(Mumei, {
childList: true,
});
let Main_Menu = new MutationObserver((E) => {
if(Achan===null)return
if (Main_Menu_Fram.style.display=="none")return
Main_Menu_Fram.style.display = "none"
Node_List[Achan].Isspam = true;
Node_List[Achan].node.querySelector("#message").style.opacity = 0.3
let Main_Menu_Click
switch (Node_List[Achan].act){
case "Block":
Main_Menu_Click= Main_Menu_Box[1]
Mes(language_("User has been blocked","用户已屏蔽","ユーザーがブロックされました"))
break;
case "Unblock":
Main_Menu_Click= Main_Menu_Box[1]
Mes(language_("Unblocked","已解除封锁","ブロック解除"))
Achan=null
Main_Menu_Click&&Main_Menu_Click.children[0].children[0].click()
return
break;
case "Report":
Main_Menu_Click= Main_Menu_Box[0]
Mes(language_("Comment has been reported","已举报评论","コメントが報告されました"))
}
if(window.getComputedStyle(Node_List[Achan].node.querySelector("#deleted-state"), null).getPropertyValue('display')!="none")return
Achan=null
Main_Menu_Click&&Main_Menu_Click.children[0].children[0].click()
});
let Dialogs = new MutationObserver((E) => {
if (Dialogs_Confirm_Fram.style.display=="none")return
Dialogs_Confirm_Fram.style.display="none"
Dialogs_Confirm.children[0].children[0].click();
});
let Report_Menu = new MutationObserver((E) => {
if (Report_Menu_Fram.style.display=="none")return
Report_Menu_Fram.style.display="none"
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', '')
Report_Menu_report.click();
});
}
function DellArray(V,Array){
let Fubigi = [];
for (let i= Array.length-1;i>=0;i--){
if(Array[i].proto==V){
Array.splice(i, 1)
}
}
Array = Array.filter((item)=>{
let Na=Fubigi.includes(item.proto)
!Na&&Fubigi.push(item)
return !Na
})
return Array
}
function GetKey(en) {
en=en.replace(re, "")
let items=Array.from(en,(x,i)=>".*"+x).join("")
return items+".*"
}
pro.style.width=wi+"px";
pro.setAttribute('class', 'pro')
pro.style.visibility = "hidden"
TOPdiv.onmouseout = function(e){
let meslog
if(e.target.id=="Log_Name"||e.target.id=="Log_Message"){
clearTimeout(korone);korone=null
meslog = e.target.parentNode.nextElementSibling
if (meslog.children.length){
if (meslog.style.display == ""){
setTimeout(()=>{
meslog.style.display="none"
},10000)
}
}else{
e.target.style.background=""
}
}
}
TOPdiv.onmouseover =function(e){
let mes_log_div,meslog,I=0,ISBBQ = 0,LogN = []
switch (e.target.id)
{
case "Log_Name":
meslog = e.target.parentNode.nextElementSibling
meslog.innerHTML= ""
ShowGO(e.target.parentNode.id,meslog,"Name")
e.target.nextElementSibling.style.display=""
clearTimeout(korone);korone=null
korone=setTimeout(()=>{
meslog.style.display=""
},400)
break;
case "Log_Message":
meslog = e.target.parentNode.nextElementSibling
meslog.innerHTML= ""
ShowGO(e.target.innerText,meslog,"Mes")
e.target.nextElementSibling.style.display=""
clearTimeout(korone);korone=null
korone=setTimeout(()=>{
meslog.style.display=""
},400)
}
}
TOPdiv.onclick=(e)=>{
let GTA,LogNames = [],logn,mes_log_div,meslog,E,ssd,max
switch (e.target.id)
{
case "Set_off":
TOPdiv.style.visibility="hidden";
AllLog.style.visibility = "hidden"
Category.disabled = false
Category.selectedIndex=0
document.getElementById("Untreated_").value =Untreated+ " " + language_("Untreated", "未处理", "未処理")
BlockLogs.innerHTML=null
LogShow.checked =false
break;
case "ISblock":
Isblock = ISblock.checked?"checked":" "
Kirara=ISblock.checked
localStorage.setItem("IsBlock",Isblock)
break;
case "ISreplace":
Isreplace = ISreplace.checked?"checked":" "
Ame=ISreplace.checked
localStorage.setItem("Isreplace",Isreplace)
break;
case "Log_Show":
Node_Log_List= Node_List.filter((item)=>{
let Na = true
if (item.Isspam&&!item.Isblock){
Na=LogNames.includes(item.name_src)
!Na&&LogNames.push(item.name_src)
}
return !Na
})
Gura =LogShow.checked
Untreated_.value = Untreated+ " " + language_("Untreated", "未处理", "未処理")
if(!Gura){
BlockLogs.innerHTML=null
AllLog.style.visibility = "hidden"
Category.selectedIndex=0
Category.disabled = false
return
}
BlockLogs.style.height = "414px"
AllLog.style.visibility = "visible"
PageMode = doc;pages=doc;Page=0;PageN = 1
document.getElementById("page_").value = PageN
Log_List(Node_Log_List,Page,pages,"name")
show_l()
BlockLogs.scrollTop=BlockLogs.scrollHeight
break;
case "IS__Block":
Achan=Number(e.target.parentNode.id)
GTA=Node_List[Achan]
ssd = e.target.parentNode.previousElementSibling
if(!GTA.Isblock){
Node_List.forEach((mes)=>{
if (GTA.name_src === mes.name_src){
let cdk=mes.Message.trim()
KeyItemList.some((item)=>{
let Key_On = new RegExp(item.regexp).test(cdk)
if(Key_On)item.spam=true;
return Key_On;
})
mes.Isspam=true
mes.Isblock =true
GTA.act = "Block"
}
})
}else{
Node_List.forEach((mes)=>{
if (Node_List[Achan].name_src === mes.name_src){
if(mes.Isblock)mes.Isblock = false
GTA.act = "Unblock"
}
})
}
if (ssd.id == "Log_Message")ssd.style.opacity=0.3
if (ssd.id == "Log_Message")e.target.disabled = true
Queue(GTA.node,Achan)
shion_p.innerText=count()
Untreated_.value = Untreated+ " " + language_("Untreated", "未处理", "未処理")
break;
case "IS_All_Block":
E=e.target.parentNode.parentNode.nextElementSibling
ssd = e.target.parentNode.previousElementSibling
for(let i = 0,L= E.children.length;i<L;i++){
let mes = Node_List[E.children[0].id]
Node_List.forEach((node)=>{
if(node.name_src == mes.name_src)node.Isblock=true
})
mes.act = "Block"
Queue(mes.node,E.children[0].id)
E.children[0].remove()
}
shion_p.innerText=count()
ssd.style.opacity=0.3
e.target.disabled = true
Untreated_.value = Untreated+ " " + language_("Untreated", "未处理", "未処理")
}
}
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
},300)
}
document.querySelector("#Category_sort").onchange=()=>{
BlockLogs.style.height = "414px"
BlockLogs.innerHTML=null
PageMode = doc;pages=doc;Page=0;PageN = 1
let Selector = document.querySelector("#Category_sort").value
if(Selector == "Mes_length"){
let LogMes = []
Node_Log_List = Node_List.filter((item)=>{
let Na = true
if(item.Isspam&&!item.Isblock){
Na=LogMes.includes(item.Message)
!Na&&LogMes.push(item.Message)
}
return !Na
})
sort(false,Selector,Node_Log_List)
Log_List(Node_Log_List,Page,pages,"mes",true)
show_l()
}else if(document.querySelector("#Category_sort").value == "Blocked"){
let Na = true,LogNames= []
Node_Log_List=Node_List.filter((item)=>{
Na = true
if (item.Isblock){
Na=LogNames.includes(item.name_src)
!Na&&LogNames.push(item.name_src)
}
return !Na
})
Log_List(Node_Log_List,Page,pages,"name")
show_l()
}else{
let LogNames= []
Node_Log_List = Node_List.filter((item)=>{
let Na = true
if (item.Isspam){
Na=LogNames.includes(item.name_src)
!Na&&LogNames.push(item.name_src)
}
return !Na
})
sort(false,Selector,Node_Log_List)
Log_List(Node_Log_List,Page,pages,"name")
show_l()
}
document.querySelector("#page_").value = 1
BlockLogs.scrollTop=BlockLogs.scrollHeight
}
function Log_List(Log_ty,Page,pages,Name,Is_a_d){
BlockLogs.innerHTML=null
let Fragment = document.createDocumentFragment(),BB=0
if(Name)YMD_Type = Name;
YMD = Log_ty;
Pageleng = Log_ty.length
for(let i = Page;i<pages;i++){
let div = Coco.cloneNode(true);
let ms_item_list=div.querySelector("#mes_log")
if(!Log_ty[i])break;
div.querySelector("#antetype").parentNode.id = Log_ty[i].name_src
div.querySelector("#antetype").id= Log_ty[i].index
div.style.backgroundColor=BB%2==0?WTF_1:WTF_2
let logn=div.querySelector("#Log_Name")
logn.innerText = Log_ty[i].name;
if (YMD_Type=="mes"){
logn.id = "Log_Message"
logn.innerText = Log_ty[i].Message
}
let input =div.querySelector("#Unblock")
input.title = language_("Unblock or block users","解除或屏蔽用户","ユーザーのブロックを解除またはブロックする")
Is_a_d?input.id="IS_All_Block":input.id="IS__Block"
if(!Is_a_d&&Log_ty[i].Isblock&&YMD_Type=="mes"){
div.querySelector("#IS__Block").setAttribute('checked', '');
input.disabled = true
div.style.opacity=0.3
}else if(Is_a_d&&Is_a_d&&Log_ty[i].Isblock&&YMD_Type=="mes"){
div.querySelector("#IS__Block").setAttribute('checked', '');
input.disabled = true
div.style.opacity=0.3
} else if(Log_ty[i].Isblock){
div.querySelector("#IS__Block").setAttribute('checked', '');
}
div.style.display = "";
BB++
Fragment.appendChild(div)
}
shion_p.innerText=count()
Untreated_.value =Untreated+ " " + language_("Untreated", "未处理", "未処理")
BlockLogs.appendChild(Fragment)
max_.value = "Max:"+ Math.ceil(Pageleng/PageMode)
BlockLogs.scrollTop=BlockLogs.scrollHeight
}
function show_l(){
for(let i = 0 ,I=BlockLogs.children.length;i<I;i++){
let it = YMD_Type=="mes" ? BlockLogs.children[i].querySelector("#Log_Message").innerText:BlockLogs.children[i]?.querySelector("#Log_Name")?.parentNode?.id
let name = YMD_Type=="mes" ? "Mes":"Name"
let add=BlockLogs.children[i].querySelector("#mes_log")
ShowGO(it,add,name)
add.previousElementSibling.children[1].style.display=""
add.style.display=""
}
}
function ShowGO(it,add,name){
let LogN =[]
if(name=="Name"){
Node_List.forEach((mes,i)=>{
if(mes.Isspam&&mes.name_src===it){
let Na=LogN.includes(mes.Message)
!Na&&LogN.push(mes.Message)
if(Na)return;
let mes_log_div = document.createElement("div");
mes_log_div.innerText = mes.Message
if(mes.interval<2)add.parentNode.style.background="rgba(255, 218, 74, 0.2) "
add.appendChild(mes_log_div)
}
})
}else if(name=="Mes"){
Node_List.forEach((mes,i)=>{
if(!mes.Isblock&&it === mes.Message){
let Na=LogN.includes(mes.name_src)
!Na&&LogN.push(mes.name_src)
if(Na)return;
let mes_log_div = document.createElement("div");
mes_log_div.innerText = mes.name
mes_log_div.id = mes.index
if(mes.interval<2)add.parentNode.style.background="rgba(255, 218, 74, 0.2) "
add.appendChild(mes_log_div)
}
})
}else{
}
}
function count(){
Untreated = 0;Spam = 0; Normal = 0
for (let i =0,L=Node_List.length;i<L;i++ ){
if(Node_List[i].Isspam ===null){
Untreated++
}else if(Node_List[i].Isspam){
Spam++
}else if(!Node_List[i].Isspam){
Normal++
}
}
return "Spam:"+Spam+" |Normal:"+ Normal + " |Untreated:"+ Untreated
}
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) return Sort?-1:1
if (x > y) return Sort?1:-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 Zoo(){
let zoo=["にゃん","モグ","ワン","パチ","ピカ","ガオ"]
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
}
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
if(!document.body.contains(Node_List[Achan].node))Dump.appendChild(Node_List[Achan].node)
Delet_mes.node.querySelector("#button.yt-icon-button").click()
Deleting = setTimeout(()=>{
Del_List.length?Queue():Deleting=null
},Delete_interval)
}
}
const nullll = GM_registerMenuCommand("┏━━━━━━━━━━━━━━━━━━━━┓", () => {
});
const AR = GM_registerMenuCommand("AutoReport", () => {
AutoReport=AutoReport?false:true
});
const nullll1 = GM_registerMenuCommand("┣━━━━━━━━━━━━━━━━━━━━┫", () => {
});
const Start = GM_registerMenuCommand(language_("Click this to restart after Top chat/Live chat","切换重要/实时聊天后单击这里重启","上位チャット/チャット変更後にクリックして再起動"), () => {
if(!(document.body.contains(Itemslist))){
Itemslist = document.querySelector("#items.yt-live-chat-item-list-renderer");
Yagoo.observe(Itemslist, {
childList: true,
})
}
});
const nullll11 = GM_registerMenuCommand("┗━━━━━━━━━━━━━━━━━━━━┛", () => {
});
Menu_Set()
})();