FE Chat Highlighter

Highlight FE chat

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         FE Chat Highlighter
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Highlight FE chat
// @author       Natty_Boh
// @include      https://www.finalearth.com/*
// @include      https://finalearth.com/*
// ==/UserScript==

highlight()
listen()

/*
********
USER EDITABLE SECTION STARTS HERE

keywordsToHighlight -- highlight username by default.
Add additional keywords by adding them inside double quotes and comma separated (case insensitive), examples [userName, "natty", "nat"]

userNameColor - color of your name in message you sent

keywordHighlightColor - highlight color of messages containing your selected keywords

https://www.w3schools.com/colors/colors_names.asp see options here for different colors you can replace with to customize your color scheme

********
*/

let keywordsToHighlight = [userName]
let userNameColor = "crimson"
let keywordHighlightColor = "lightPink"

/*
********
USER EDITABLE SECTION ENDS HERE
********
*/

function listen() {
   var observer = new MutationObserver(function(mutations) {
			mutations.forEach(function(m) {
				if (m.addedNodes[1] && m.addedNodes[1].classList && m.addedNodes[1].classList.contains("message")) {
                    highlight()
				}
			}
		)});

    var target = document.querySelector(".chat-box-wrap");
    var config = {
        childList: true,
        subtree: true
    }

    observer.observe(target, config);

}

function highlight(){
    document.querySelectorAll('a').forEach( e => {
        if (e.textContent.includes(userName)) {
            e.style.color = 'crimson'
        }
    });
     document.querySelectorAll('.message > span').forEach( e => {
         var text = e.textContent.toLowerCase();
        if (keywordsToHighlight.some(element => text.includes(element.toLowerCase()))) {
            e.style.backgroundColor = 'lightPink'
        }
    });



}