Greasy Fork is available in English.
치지직 채팅의 닉네임 색상입히기 / 치즈 메시지 숨기기
当前为
// ==UserScript==
// @name 치지직 채팅창 설정
// @namespace https://yoonu.io/
// @version 0.1
// @description 치지직 채팅의 닉네임 색상입히기 / 치즈 메시지 숨기기
// @author Yoonu
// @match https://chzzk.naver.com/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=chzzk.naver.com
// @grant none
// @license MIT
// ==/UserScript==
// 치즈 메시지 제거하기 ( 사용하고 싶으면 true / 사용하기 싫으면 false 입력 )
const removeCheeze = true;
// 닉네임 색상 목록
const color_list = [
"rgb(255, 0, 0)",
"rgb(0, 0, 255)",
"rgb(0, 128, 0)",
"rgb(178, 34, 34)",
"rgb(255, 127, 80)",
"rgb(154, 205, 50)",
"rgb(255, 69, 0)",
"rgb(46, 139, 87)",
"rgb(218, 165, 32)",
"rgb(210, 105, 30)",
"rgb(95, 158, 160)",
"rgb(30, 144, 255)",
"rgb(255, 105, 180)",
"rgb(138, 43, 226)",
"rgb(0, 255, 127)"
];
(function() {
'use strict';
const callback = () => {
const targetNode = document.querySelector("#layout-body > section > aside");
if(targetNode)
colorizeChat(targetNode)
}
const observer = new MutationObserver(callback);
observer.observe(document.getElementById("layout-body"), { attributes: false, childList: true, subtree: false });
})();
const colorizeChat = (chatNode) => {
const callback = (mutationList, observer) => {
for (const mutation of mutationList) {
if (mutation.type !== "childList")
continue
for(let addedNode of mutation.addedNodes) {
// 치즈 메시지 제거
if(removeCheeze && addedNode.classList.contains("live_chatting_list_donation__Fy6Vz")) {
addedNode.classList.add("blind");
continue;
}
const nickNode = addedNode.querySelector(".name_text__yQG50");
setNicknameColor(nickNode)
}
}
};
const observer = new MutationObserver(callback);
observer.observe(chatNode, { attributes: false, childList: true, subtree: true });
}
const setNicknameColor = (node) => {
const nickname = node.innerText;
let val = 0;
if (nickname.length > 0) {
for (let i = 0; i < nickname.length; i++)
val += nickname.charCodeAt(i);
}
node.style.color = color_list[val % color_list.length];
}