// ==UserScript==
// @name GameMale植物属性染色4.0
// @namespace http://tampermonkey.net
// @version 4.0
// @description 在记录中对用户id染色成对应的植物属性颜色(向日葵红色,豌豆绿色,坚果蓝色),单击网页右上角按钮染色,再单击还原。
// @author 您的名字
// @match https://www.gamemale.com/home.php?mod=space*
// @match https://www.gamemale.com/thread-189511*
// @grant none
// @run-at document-end
// ==/UserScript==
(function() {
'use strict';
// ====================================================
// 【 词 段 批 量 维 护 区 】
// 您只需要在这里增删词段,每个词用英文逗号和单引号隔开即可。
// ====================================================
// 【红色组】向日葵
const RED_WORDS = [
'喵喵向日葵', '向日葵', '相见忧', 'zachariah', 'zibatco2', 'zhanji1983', '2297988', '亚洛斯', 'Burry', 'Hi_Speedsky', '牙旋暗雾', 'Kaoruji', '点击输入文字', 'XLK', 'zzq19930719', '52aro', '庹旯', '走失伯劳', '桀桀桀', 'RuacoonX', '三分春色描来易', 'xrxw05', '焦糖可颂', '小蓝龙泷泽', 'scious', 'oo98ii', 'glq723', '雨停了我就回来', 'Rasmus', 'ttldmm', '墨燝', '5kk', 'raccooncop', '呆到自然蠢', '找乐子企鹅仔', 'lwymmd', 'shib023', '164895785', '豆虎脑', '海歌川行', 'chenfeng6', '小龍小開心', 'Zeperion', '流星雨丶lxu', '大白呀', 'shao126', 'ddbGameMale', '名不到啊', 'CHMHS', '凯登', 'DIMDANMAS', 'kibody', '王木木', 'cinder', '飞扬fox', 'drhung', 'priestlv99', '白氿', '阿扳', 'Inari', 'ElisaZero', 'a1l2t3', '我就上来看看', '野生阿努厨', '莫空山', '亓岳', '北苍霜月', '千城墨白', 'Brine', '西伯利亚白刺', 'maxgg', '本地人', 'Magicskull', '水晶螳螂', '我们一起学狗叫', '2337891498', '黑狼熽', '唉咯L', 'okild', '丢人代言人', 'shirley1213', '七曜魔女', 'HansenDog', 'RaphaelJC', 'crino66666', 'a1b2a9', '黑暗哈德', 'miniQ', 'Derplander', 'user0516', 'Vins', 'Radiant', 'sc_6636', 'zyl414395594', 'MoJIJI', 'RAMEN_DiSK', 'ethelcain', 'lishan', '一只随行', 'huakaiwusheng', 'cwbf', 'Qxia1010', 'hs90419a', '克莱因蓝', 'Raven_gambler', 'talkspecial', '犬傑犬', 'Yoichiqzuser', 'huiguo', 'a0015100151', 'cdcai', '死物公文', 'zjw', '海瑞瑟', 'wppp', 'Okabe', 'FrozenFrost', 'tammy7908', '轮回2L', '小晨风', 'Ter丶夫', 'ELR', '刀火', 'hylfs001', '泠泠泠泠', 'Rochelimit', 'FTfan', 'zhb9576', '尹兮', 'oct', 'nercomancer', 'azna', 'Floopa', '尹宕守', 'AHM.R', 'Dust#', 'LeoCastro', '哈奇姆', 'singto', 'ga2006024244', 'lushishan', 'KamiuBlued', '2254921', '水水水冘', '旧梦已逝', 'e1194493573', '古珀川早见', '肥鱼', '赴约波波', 'QZONE', 'liuhuo0', '辰翊', 'anzx0', 'FengYing', '原炀小狼狗', '被宽恕的色欲', '大玄子', 'dachuan_', 'crabee', '游魂谷', '雨雨子', 'abba', 'Wohoom', 'c8g4fu6', '湖南安', 'rogay', '是KUMAyo', 'zzy159', 'jbtty', 'Tzx_tuzi', '安总认定的好人', '1017186309', '33966', '弗爾豪斯', '伊犁鼠兔吃雪莲', 'davidhigrid', 'Colten', 'gungun', 'duoan', 'a0010028', '95269527', '乔舒亚', '汉堡', 'boowak03', 'kazmaking', '哇啦哇啦', '上树', 'Leo梅西', '不在彩虹脚下', 'heihei', '谢谢下一个', '一杯水', 'donkey01', 'parting', 'Riverlethe', 'akersD', '一万只小仓鼠', '神必quin', '哈哈哈哈_', 'boshen', 'Remus7', 'davidliau', '1417432518', 'zhuovboyan', '艾维叶叶', 'wdhgzdhcxb', 'ComParo', '雾岛渐次ka',
// 您可以在这里继续往下加 100 个词,例如:
// '词段1', '词段2', '词段3'
];
// 【绿色组】豌豆
const GREEN_WORDS = [
'樱桃豌豆射手', '射手','豌豆','li2226' ,'天恩','_清青_', '武翊', '冰刃白牙', '紫-漾', 'Zihho', '金苹果', 'yandong', 'YJ3', 'xuhosen', '阿又', 'Qacc', '黑炭先森', '毛茸茸的黑貓', 'Fenriusclaws', 'ilblvm', 'thh866', 'HAKUNA MATATA', '星河一隅', 'KurisuV', 'hellseasons', '抢ID可耻', '夏飞千',
// 您可以在这里继续往下加 100 个词...
];
// 【蓝色组】坚果
const BLUE_WORDS = [
'贪财罐坚果','坚果', 'Moonglow', '娱乐法师火布偶', '深暗幽狼','aaawwwww', 'Sam30', '红叶黄花', 'horizonLd', '因本', '咸鱼鱼', 'you9632587', '你好再见', 'Geoff', '是阿行嘞', '安氏贵人鸟', 'PURO_', 'RaSharim', 'rockdjs', 'PUCK', '蓝灯', 'Ghost-in-System', '熊赳赳', 'Applause', '书の妖怪', '柏芸', '凯诺斯', 'Makima', '高希声', 'reober3', '仲裁丶火炬', 'Yeries', '影哨', 'Freeze123', 'Rolf_0', '狂野哈士奇', '傲瑞龍兽', '歧路歌', 'pleitgen', 'FUGEE', 'danmudeng', 'Morphyus', '帝王心術', 'yota', 'leochan', 'lhlzl', '大墨迹', '米立', '毛茸茸兽兽', 'White_sky', '千城丶', 'apple21000', 'Deno13', 'Se7en', 'J2isreal', '万俟', 'HAOoO', '☆Yuki☆', '虎爹', '多崎作',
// 您可以在这里继续往下加 100 个词...
];
// ====================================================
// 【 颜 色 样 式 定 义 区 】
// 如果想换颜色,只改这里即可
// ====================================================
const STYLES = {
red: { color: '#FFFFFF', bgColor: '#FF0000' },
green: { color: '#FFFFFF', bgColor: '#008000' },
blue: { color: '#FFFFFF', bgColor: '#002FA7' }
};
// ====================================================
// 【核心逻辑区】(以下代码已全部自动化,无需任何修改)
// ====================================================
// 自动将“分组词段”扁平化处理,建立高效的运行时快速索引
const COLOR_CONFIG = {};
RED_WORDS.forEach(word => COLOR_CONFIG[word] = STYLES.red);
GREEN_WORDS.forEach(word => COLOR_CONFIG[word] = STYLES.green);
BLUE_WORDS.forEach(word => COLOR_CONFIG[word] = STYLES.blue);
const TARGET_TEXTS = Object.keys(COLOR_CONFIG);
let isColoringEnabled = false;
let observer = null;
let timer = null;
// 创建并插入“显示植物属性”开关按钮
function createSwitchButton() {
const btn = document.createElement('button');
btn.id = 'gm-plant-switch-btn';
btn.textContent = '显示植物属性:OFF';
Object.assign(btn.style, {
position: 'fixed', top: '80px', right: '20px', zIndex: '99999',
padding: '8px 14px', backgroundColor: '#f1f1f1', color: '#333',
border: '1px solid #ccc', borderRadius: '4px', cursor: 'pointer',
fontWeight: 'bold', boxShadow: '0 2px 5px rgba(0,0,0,0.2)', transition: 'all 0.3s ease'
});
btn.onmouseover = () => { btn.style.filter = 'brightness(0.9)'; };
btn.onmouseout = () => { btn.style.filter = 'none'; };
btn.addEventListener('click', function() {
isColoringEnabled = !isColoringEnabled;
if (isColoringEnabled) {
btn.textContent = '显示植物属性:ON';
btn.style.backgroundColor = '#4CAF50'; btn.style.color = '#fff'; btn.style.borderColor = '#388E3C';
startColoring();
} else {
btn.textContent = '显示植物属性:OFF';
btn.style.backgroundColor = '#f1f1f1'; btn.style.color = '#333'; btn.style.borderColor = '#ccc';
stopColoringAndRestore();
}
});
document.body.appendChild(btn);
}
// 执行染色的核心函数
function modifyGameMaleSpace() {
if (!isColoringEnabled || TARGET_TEXTS.length === 0) return;
const textNodes = document.evaluate("//text()", document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
for (let i = 0; i < textNodes.snapshotLength; i++) {
const node = textNodes.snapshotItem(i);
const parent = node.parentNode;
if (parent && parent.className !== 'gm-plant-highlight' && !['SCRIPT', 'STYLE', 'INPUT', 'TEXTAREA', 'BUTTON'].includes(parent.tagName)) {
let text = node.nodeValue;
TARGET_TEXTS.forEach(target => {
if (text.includes(target)) {
const config = COLOR_CONFIG[target];
const span = document.createElement('span');
span.className = 'gm-plant-highlight';
span.style.color = config.color;
span.style.backgroundColor = config.bgColor;
span.style.fontWeight = 'bold';
span.style.borderRadius = '3px';
span.style.padding = '0 4px';
span.style.margin = '0 2px';
span.textContent = target;
const segments = text.split(target);
parent.insertBefore(document.createTextNode(segments[0]), node);
parent.insertBefore(span, node);
node.nodeValue = segments.slice(1).join(target);
text = node.nodeValue;
}
});
}
}
}
function startColoring() {
modifyGameMaleSpace();
observer = new MutationObserver(() => {
if (timer) clearTimeout(timer);
timer = setTimeout(() => { modifyGameMaleSpace(); }, 100);
});
observer.observe(document.body, { childList: true, subtree: true });
}
function stopColoringAndRestore() {
if (observer) { observer.disconnect(); observer = null; }
const highlights = document.querySelectorAll('.gm-plant-highlight');
highlights.forEach(span => {
const parent = span.parentNode;
if (parent) {
const textNode = document.createTextNode(span.textContent);
parent.replaceChild(textNode, span);
parent.normalize();
}
});
}
createSwitchButton();
})();