版本比较
洛谷内容净化器——为您的洛谷使用体验保驾护航,不仅限于洛谷!
标题
增加 1 行删除 1 行
11洛谷内容净化器——为您的犇犇使用体验保驾护航!洛谷内容净化器——为您的洛谷使用体验保驾护航,不仅限于洛谷!正文
增加 12 行删除 867 行
1123356789101112131415161718194521226724252627892930311011331213353637383940414243444546474849501452535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685715161718192021859860861862863864865866867868869870871872873874875876如今,洛谷犇犇惊现一群猫粮与南梁,让人观犇体验骤降且有同化趋势。 **由AI辅助完成**
为预防此类现象,维护洛谷犇犇观看安全,本人使用DeepSeek编写了一个油猴脚本,专门预防此类现象。
::::info[脚本代码(更新请关注@ [WJRAK's Article](https://www.luogu.com.cn/user/1695884/article))] ```javascript// ==UserScript==// @name 洛谷内容净化器// @namespace http://tampermonkey.net/// @version 5.1// @description 专门屏蔽洛谷一些让人不适的词汇(支持替换和删除)// @author WJRAK&DeepSeek// @match *://*/*// @grant GM_setValue// @grant GM_getValue// @grant GM_registerMenuCommand// @run-at document-end// @license MIT// ==/UserScript==如今,洛谷犇犇惊现一群猫粮与南梁,让人观犇体验骤降且有同化趋势。
(function() { 'use strict';为保(kan)证(qi)犇(lai)犇(bu)观(e)感(xin),本人特意编写了这个脚本以解决相关问题。
// ========== 核心词库 ========== const CORE_REPLACE_WORDS = [ '南梁', '蓝梁', '香香软软', '肉文', '小黄文','猫娘','猫粮' ];::::info[脚本代码]
const CORE_DELETE_WORDS = [ '喵' ];[最新版](https://www.luogu.me/paste/nz6vxc03)
// ========== 字符映射表(用于生成所有可能的变体)==========::::
// 1. 拼音映射(包括带数字的变体) const PINYIN_MAP = { '南': ['nan', 'na', 'nán', 'nàn', 'na2', 'na4'], '蓝': ['lan', 'la', 'lán', 'làn', 'la2', 'la4'], '梁': ['liang', 'lia', 'lía', 'liàng', 'lia2', 'lia4', 'lian'], '香': ['xiang', 'xia', 'xiāng', 'xiàng', 'xia1', 'xia4'], '软': ['ruan', 'rua', 'ruǎn', 'ruàn', 'rua3', 'rua4'], '肉': ['rou', 'ro', 'ròu', 'ro4'], '文': ['wen', 'we', 'wén', 'wèn', 'we2', 'we4'], '小': ['xiao', 'xia', 'xiǎo', 'xiào', 'xiao3', 'xia3'], '黄': ['huang', 'hua', 'huáng', 'huàng', 'hua2', 'hua4'], '喵': ['miao', 'mia', 'miāo', 'miào', 'miao1', 'miao4'], '猫': ['mao', 'ma', 'māo', 'mào', 'mao1', 'mao4'], '娘': ['niang', 'nia', 'niáng', 'niàng', 'nia2', 'nia4'], '粮': ['liang', 'lia', 'liáng', 'liàng', 'lia2', 'lia4'] };
// 2. 数字替换字母 (Leet) const LEET_MAP = { 'a': '[a4@]', 'b': '[b8]', 'c': '[c(]', 'e': '[e3]', 'g': '[g9]', 'i': '[i1!]', 'l': '[l1|]', 'o': '[o0]', 's': '[s5$]', 't': '[t7]', 'z': '[z2]', 'n': '[n]', 'm': '[m]' };
// 3. 同音字映射 const HOMOPHONE_MAP = { '南': '[南男难喃楠]', '蓝': '[蓝篮兰拦栏]', '梁': '[梁粮凉粱量]', '香': '[香湘乡箱镶]', '软': '[软阮蠕]', '肉': '[肉褥]', '文': '[文纹闻蚊]', '小': '[小晓筱]', '黄': '[黄皇煌簧]', '喵': '[喵]', '猫': '[猫锚]', '娘': '[娘酿]', '粮': '[粮凉梁粱量]' };
// 4. 形近字映射 const SIMILAR_MAP = { '南': '[南茼]', '蓝': '[蓝监]', '梁': '[梁染]', '香': '[杳杏]', '喵': '[喵]', '猫': '[猫]', '娘': '[娘]', '粮': '[粮]' };
// ========== 存储键名 ========== const STORAGE_REPLACE_WORDS = 'shield_replace_words'; const STORAGE_DELETE_WORDS = 'shield_delete_words'; const STORAGE_SETTINGS = 'shield_settings';
// ========== 默认设置 ========== const DEFAULT_SETTINGS = { modePinyin: true, // 拼音匹配 modeLeet: true, // 数字替换匹配 modeHomophone: true, // 同音字匹配 modeSimilar: true, // 形近字匹配 modeFuzzy: true, // 模糊匹配(中间插字符) modeSplit: true, // 拆分匹配(如"南 梁") maxFuzzyDistance: 3, // 模糊距离 logToConsole: false // 输出日志 };
// ========== 初始化 ========== function initStorage() { if (GM_getValue(STORAGE_REPLACE_WORDS, null) === null) { GM_setValue(STORAGE_REPLACE_WORDS, CORE_REPLACE_WORDS); } if (GM_getValue(STORAGE_DELETE_WORDS, null) === null) { GM_setValue(STORAGE_DELETE_WORDS, CORE_DELETE_WORDS); } if (GM_getValue(STORAGE_SETTINGS, null) === null) { GM_setValue(STORAGE_SETTINGS, DEFAULT_SETTINGS); } } initStorage();
// ========== 获取数据 ========== function getReplaceWords() { return GM_getValue(STORAGE_REPLACE_WORDS, []); } function getDeleteWords() { return GM_getValue(STORAGE_DELETE_WORDS, []); } function getSettings() { return GM_getValue(STORAGE_SETTINGS, DEFAULT_SETTINGS); }
// ========== 更新 ========== function updateAll(newReplaceWords, newDeleteWords, newSettings) { GM_setValue(STORAGE_REPLACE_WORDS, newReplaceWords); GM_setValue(STORAGE_DELETE_WORDS, newDeleteWords); GM_setValue(STORAGE_SETTINGS, newSettings); processDocument(); }
// ========== 转义正则 ========== function escapeRegExp(string) { return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); }
// ========== 生成拼音变体 ========== function generatePinyinVariants(word) { let variants = [];
for (let i = 0; i < word.length; i++) { const char = word[i]; const pinyins = PINYIN_MAP[char] || [char];
if (variants.length === 0) { variants = [...pinyins]; } else { const newVariants = []; variants.forEach(v => { pinyins.forEach(p => { newVariants.push(v + p); }); }); variants = newVariants; } }
return variants; }
// ========== 生成Leet模式 ========== function createLeetPattern(text) { let pattern = ''; for (let char of text.toLowerCase()) { if (LEET_MAP[char]) { pattern += LEET_MAP[char]; } else { pattern += char; } } return pattern; }
// ========== 生成单个词的所有模式 ========== function generatePatternsForWord(word, settings) { const patterns = new Set();
// 1. 原词 patterns.add(escapeRegExp(word));
// 2. 拆分匹配 if (settings.modeSplit) { patterns.add(word.split('').join('\\s*')); }
// 3. 模糊匹配 if (settings.modeFuzzy) { const chars = word.split(''); patterns.add(chars.join(`[^<>]{0,${settings.maxFuzzyDistance}}`)); }
// 4. 同音字匹配 if (settings.modeHomophone) { let homoPattern = ''; for (let char of word) { if (HOMOPHONE_MAP[char]) { homoPattern += HOMOPHONE_MAP[char]; } else { homoPattern += char; } } patterns.add(homoPattern); }
// 5. 形近字匹配 if (settings.modeSimilar) { let similarPattern = ''; for (let char of word) { if (SIMILAR_MAP[char]) { similarPattern += SIMILAR_MAP[char]; } else { similarPattern += char; } } patterns.add(similarPattern); }
// 6. 拼音变体 if (settings.modePinyin || settings.modeLeet) { const pinyinVariants = generatePinyinVariants(word); pinyinVariants.forEach(py => { patterns.add(py);
if (settings.modeLeet) { patterns.add(createLeetPattern(py)); }
if (settings.modeSplit) { patterns.add(py.split('').join('\\s*')); }
if (settings.modeFuzzy) { const chars = py.split(''); patterns.add(chars.join(`[^<>]{0,${settings.maxFuzzyDistance}}`)); } }); }
return Array.from(patterns); }
// ========== 构建正则 ========== function buildPatterns(settings) { const replaceWords = getReplaceWords(); const deleteWords = getDeleteWords();
let replacePatterns = []; let deletePatterns = [];
// 生成替换词模式 replaceWords.forEach(word => { const patterns = generatePatternsForWord(word, settings); replacePatterns = replacePatterns.concat(patterns); });
// 生成删除词模式 deleteWords.forEach(word => { const patterns = generatePatternsForWord(word, settings); deletePatterns = deletePatterns.concat(patterns); });
// 去重排序 replacePatterns = [...new Set(replacePatterns)].sort((a, b) => b.length - a.length); deletePatterns = [...new Set(deletePatterns)].sort((a, b) => b.length - a.length);
return { replacePattern: replacePatterns.length > 0 ? new RegExp(replacePatterns.join('|'), 'gi') : null, deletePattern: deletePatterns.length > 0 ? new RegExp(deletePatterns.join('|'), 'gi') : null }; }
// ========== 测试函数 ========== function testMatching() { const settings = getSettings(); const { replacePattern, deletePattern } = buildPatterns(settings);
const testCases = [ // 替换词测试 '南梁', '南[梁', '南-梁', '南 梁', 'nanliang', 'na4nliang', '男梁', '蓝梁', '香香软软', '香 香 软 软', 'xiangxiangruanruan', '肉文', 'rouwen', 'ro4we2', '小黄文', 'xiaohuangwen', 'xiao2huang2wen2', // 删除词测试 '喵', '喵喵', 'miaomiao', 'miao', 'mi4o', '喵喵喵', '猫' ];
console.log('【测试】替换模式:', replacePattern); console.log('【测试】删除模式:', deletePattern); console.log('【测试】匹配结果:');
testCases.forEach(test => { let result = '❌'; if (replacePattern) { replacePattern.lastIndex = 0; if (replacePattern.test(test)) result = '✅ 替换'; } if (deletePattern && result === '❌') { deletePattern.lastIndex = 0; if (deletePattern.test(test)) result = '✅ 删除'; } console.log(` "${test}" → ${result}`); }); }
// ========== 核心处理函数 ========== function processDocument() { const settings = getSettings(); const { replacePattern, deletePattern } = buildPatterns(settings);
if (!replacePattern && !deletePattern) return;
if (settings.logToConsole) { console.log('【内容净化器】启动'); }
function walk(node) { if (node.nodeType === Node.TEXT_NODE) { if (!node.nodeValue.trim()) return;
let text = node.nodeValue; let originalText = text;
// 先执行删除(优先级高) if (deletePattern) { text = text.replace(deletePattern, (match) => { if (settings.logToConsole) { console.log('【删除】', match); } return ''; }); }
// 再执行替换 if (replacePattern) { text = text.replace(replacePattern, (match) => { if (settings.logToConsole) { console.log('【替换】', match, '→ (已屏蔽)'); } return '(已屏蔽)'; }); }
if (text !== originalText) { node.nodeValue = text; } } else if (node.nodeType === Node.ELEMENT_NODE) { if (/^(script|style|textarea|input)$/i.test(node.tagName)) { return; } for (let child of node.childNodes) { walk(child); } } }
if (document.body) { walk(document.body); } }
// ========== 监听动态内容 ========== function observeMutations() { const observer = new MutationObserver((mutations) => { if (observer.timeout) clearTimeout(observer.timeout); observer.timeout = setTimeout(processDocument, 300); });
observer.observe(document.body, { childList: true, subtree: true, characterData: true }); }
// ========== 创建设置面板 ========== function createSettingsPanel() { if (document.getElementById('gm-settings-panel')) return;
let currentReplaceWords = getReplaceWords(); let currentDeleteWords = getDeleteWords(); let currentSettings = getSettings();
// 创建遮罩层 const overlay = document.createElement('div'); overlay.id = 'gm-settings-overlay'; overlay.style.cssText = ` position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 999998; display: none; justify-content: center; align-items: center; `;
// 创建面板 const panel = document.createElement('div'); panel.id = 'gm-settings-panel'; panel.style.cssText = ` background: white; width: 650px; max-width: 90%; max-height: 85vh; border-radius: 12px; box-shadow: 0 10px 40px rgba(0,0,0,0.3); padding: 24px; font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; color: #333; overflow-y: auto; position: relative; `;
// ========== 标题 ========== const title = document.createElement('h2'); title.textContent = '🛡️ 洛谷内容净化器'; title.style.cssText = ` margin: 0 0 16px 0; font-size: 1.5rem; border-bottom: 2px solid #eaeef2; padding-bottom: 8px; `; panel.appendChild(title);
// ========== 说明文字 ========== const desc = document.createElement('p'); desc.innerHTML = '替换词:南梁、蓝梁、香香软软、肉文、小黄文 → (已屏蔽)<br>删除词:喵 → 直接消失'; desc.style.cssText = ` font-size: 0.95rem; color: #666; margin-bottom: 20px; padding: 12px; background: #f0f3f5; border-radius: 8px; border-left: 4px solid #c44536; `; panel.appendChild(desc);
// ========== 匹配模式设置 ========== const modeContainer = document.createElement('div'); modeContainer.style.cssText = ` background: #f8f9fa; border-radius: 10px; padding: 18px; margin-bottom: 20px; border: 1px solid #e0e0e0; `;
const modeTitle = document.createElement('div'); modeTitle.innerHTML = '🔍 <strong>匹配模式</strong>'; modeTitle.style.cssText = ` margin-bottom: 16px; font-size: 1.1rem; `; modeContainer.appendChild(modeTitle);
// 模式列表 const modes = [ { id: 'modePinyin', label: '拼音匹配', desc: 'nanliang → 南梁', color: '#2c3e50' }, { id: 'modeLeet', label: '数字替换', desc: 'na4nliang → 南梁', color: '#c44536' }, { id: 'modeHomophone', label: '同音字', desc: '男梁 → 南梁', color: '#27ae60' }, { id: 'modeSimilar', label: '形近字', desc: '蓝监 → 蓝梁', color: '#f39c12' }, { id: 'modeFuzzy', label: '模糊匹配', desc: '南[梁 → 南梁', color: '#8e44ad' }, { id: 'modeSplit', label: '拆分匹配', desc: '南 梁 → 南梁', color: '#16a085' } ];
const modeGrid = document.createElement('div'); modeGrid.style.cssText = ` display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 15px; `;
modes.forEach(mode => { const card = document.createElement('div'); card.style.cssText = ` background: white; border-radius: 8px; padding: 12px; border: 1px solid #e0e0e0; `;
const row = document.createElement('div'); row.style.cssText = `display: flex; align-items: flex-start; gap: 10px;`;
const checkbox = document.createElement('input'); checkbox.type = 'checkbox'; checkbox.id = `mode-${mode.id}`; checkbox.checked = currentSettings[mode.id]; checkbox.style.cssText = ` width: 18px; height: 18px; margin-top: 2px; cursor: pointer; accent-color: ${mode.color}; `;
const labelDiv = document.createElement('div'); labelDiv.style.flex = '1';
const label = document.createElement('label'); label.htmlFor = `mode-${mode.id}`; label.innerHTML = `<strong style="color:${mode.color}">${mode.label}</strong>`; label.style.cssText = `display: block; cursor: pointer; font-size: 1rem; margin-bottom: 4px;`;
const descSmall = document.createElement('small'); descSmall.textContent = mode.desc; descSmall.style.cssText = `color: #666; font-size: 0.8rem; display: block;`;
labelDiv.appendChild(label); labelDiv.appendChild(descSmall);
row.appendChild(checkbox); row.appendChild(labelDiv); card.appendChild(row); modeGrid.appendChild(card); });
modeContainer.appendChild(modeGrid);
// 模糊距离设置 const distanceRow = document.createElement('div'); distanceRow.style.cssText = ` margin-top: 15px; padding: 15px; background: white; border-radius: 8px; border: 1px solid #e0e0e0; `;
const sliderContainer = document.createElement('div'); sliderContainer.style.cssText = `display: flex; align-items: center; gap: 15px;`;
const distanceLabel = document.createElement('label'); distanceLabel.htmlFor = 'fuzzy-distance'; distanceLabel.textContent = '模糊距离:'; distanceLabel.style.minWidth = '60px';
const distanceInput = document.createElement('input'); distanceInput.type = 'range'; distanceInput.id = 'fuzzy-distance'; distanceInput.min = '1'; distanceInput.max = '5'; distanceInput.value = currentSettings.maxFuzzyDistance; distanceInput.style.cssText = `flex: 1; height: 6px;`;
const distanceValue = document.createElement('span'); distanceValue.id = 'fuzzy-distance-value'; distanceValue.textContent = currentSettings.maxFuzzyDistance; distanceValue.style.cssText = ` min-width: 30px; text-align: center; font-weight: bold; color: #c44536; background: #f0f0f0; padding: 4px 8px; border-radius: 4px; `;
distanceInput.oninput = function() { distanceValue.textContent = this.value; };
sliderContainer.appendChild(distanceLabel); sliderContainer.appendChild(distanceInput); sliderContainer.appendChild(distanceValue); distanceRow.appendChild(sliderContainer); modeContainer.appendChild(distanceRow);
panel.appendChild(modeContainer);
// ========== 日志选项 ========== const logContainer = document.createElement('div'); logContainer.style.cssText = ` background: #f8f9fa; border-radius: 10px; padding: 12px 18px; margin-bottom: 20px; border: 1px solid #e0e0e0; display: flex; align-items: center; `;
const logCheckbox = document.createElement('input'); logCheckbox.type = 'checkbox'; logCheckbox.id = 'log-console'; logCheckbox.checked = currentSettings.logToConsole; logCheckbox.style.cssText = `width: 18px; height: 18px; margin-right: 10px; cursor: pointer;`;
const logLabel = document.createElement('label'); logLabel.htmlFor = 'log-console'; logLabel.innerHTML = '<strong>控制台日志</strong> (在F12控制台显示屏蔽记录)'; logLabel.style.cursor = 'pointer';
logContainer.appendChild(logCheckbox); logContainer.appendChild(logLabel); panel.appendChild(logContainer);
// ========== 替换词编辑 ========== const replaceContainer = document.createElement('div'); replaceContainer.style.cssText = ` background: #f8f9fa; border-radius: 10px; padding: 18px; margin-bottom: 20px; border: 1px solid #e0e0e0; `;
const replaceTitle = document.createElement('div'); replaceTitle.innerHTML = '<strong>🔴 替换词 (变为"已屏蔽")</strong>'; replaceTitle.style.marginBottom = '10px'; replaceContainer.appendChild(replaceTitle);
const replaceTextarea = document.createElement('textarea'); replaceTextarea.value = currentReplaceWords.join('\n'); replaceTextarea.placeholder = '每行一个词'; replaceTextarea.style.cssText = ` width: 100%; box-sizing: border-box; padding: 10px; border: 1px solid #ccc; border-radius: 6px; font-size: 0.95rem; min-height: 100px; resize: vertical; font-family: monospace; `; replaceContainer.appendChild(replaceTextarea); panel.appendChild(replaceContainer);
// ========== 删除词编辑 ========== const deleteContainer = document.createElement('div'); deleteContainer.style.cssText = ` background: #f8f9fa; border-radius: 10px; padding: 18px; margin-bottom: 20px; border: 1px solid #e0e0e0; `;
const deleteTitle = document.createElement('div'); deleteTitle.innerHTML = '<strong>🗑️ 删除词 (直接消失)</strong>'; deleteTitle.style.marginBottom = '10px'; deleteContainer.appendChild(deleteTitle);
const deleteTextarea = document.createElement('textarea'); deleteTextarea.value = currentDeleteWords.join('\n'); deleteTextarea.placeholder = '例如:喵'; deleteTextarea.style.cssText = ` width: 100%; box-sizing: border-box; padding: 10px; border: 1px solid #ccc; border-radius: 6px; font-size: 0.95rem; min-height: 80px; resize: vertical; font-family: monospace; `; deleteContainer.appendChild(deleteTextarea); panel.appendChild(deleteContainer);
// ========== 按钮区域 ========== const btnContainer = document.createElement('div'); btnContainer.style.cssText = ` display: flex; justify-content: flex-end; gap: 12px; margin-top: 10px; padding-top: 10px; border-top: 1px solid #e0e0e0; `;
// 测试按钮 const testBtn = document.createElement('button'); testBtn.innerHTML = '🔍 测试'; testBtn.style.cssText = ` padding: 8px 16px; border: 1px solid #2c3e50; background: white; color: #2c3e50; border-radius: 6px; cursor: pointer; `; testBtn.onclick = () => { testMatching(); alert('测试结果已输出到控制台'); };
// 取消按钮 const cancelBtn = document.createElement('button'); cancelBtn.innerHTML = '取消'; cancelBtn.style.cssText = ` padding: 8px 16px; border: 1px solid #ccc; background: white; border-radius: 6px; cursor: pointer; `; cancelBtn.onclick = () => { overlay.style.display = 'none'; };
// 保存按钮 const saveBtn = document.createElement('button'); saveBtn.innerHTML = '保存'; saveBtn.style.cssText = ` padding: 8px 16px; border: none; background: #2c3e50; color: white; border-radius: 6px; cursor: pointer; font-weight: 500; `; saveBtn.onclick = () => { const newReplaceWords = replaceTextarea.value.split('\n') .map(l => l.trim()) .filter(l => l);
const newDeleteWords = deleteTextarea.value.split('\n') .map(l => l.trim()) .filter(l => l);
const newSettings = { modePinyin: document.getElementById('mode-modePinyin').checked, modeLeet: document.getElementById('mode-modeLeet').checked, modeHomophone: document.getElementById('mode-modeHomophone').checked, modeSimilar: document.getElementById('mode-modeSimilar').checked, modeFuzzy: document.getElementById('mode-modeFuzzy').checked, modeSplit: document.getElementById('mode-modeSplit').checked, maxFuzzyDistance: parseInt(document.getElementById('fuzzy-distance').value), logToConsole: document.getElementById('log-console').checked };
updateAll(newReplaceWords, newDeleteWords, newSettings); overlay.style.display = 'none'; };
btnContainer.appendChild(testBtn); btnContainer.appendChild(cancelBtn); btnContainer.appendChild(saveBtn); panel.appendChild(btnContainer);
// 关闭按钮 const closeIcon = document.createElement('span'); closeIcon.innerHTML = '✕'; closeIcon.style.cssText = ` position: absolute; top: 18px; right: 24px; font-size: 1.6rem; cursor: pointer; color: #999; `; closeIcon.onclick = () => { overlay.style.display = 'none'; }; panel.appendChild(closeIcon);
overlay.appendChild(panel); document.body.appendChild(overlay);
// 触发按钮 let triggerBtn = document.getElementById('gm-settings-trigger'); if (!triggerBtn) { triggerBtn = document.createElement('div'); triggerBtn.id = 'gm-settings-trigger'; triggerBtn.innerHTML = '🛡️'; triggerBtn.style.cssText = ` position: fixed; bottom: 20px; right: 20px; width: 52px; height: 52px; background: #c44536; color: white; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 26px; cursor: pointer; box-shadow: 0 4px 15px rgba(0,0,0,0.3); z-index: 999999; opacity: 0.85; border: 2px solid white; `;
triggerBtn.onclick = () => { const curReplace = getReplaceWords(); const curDelete = getDeleteWords(); const curSettings = getSettings();
replaceTextarea.value = curReplace.join('\n'); deleteTextarea.value = curDelete.join('\n');
document.getElementById('mode-modePinyin').checked = curSettings.modePinyin; document.getElementById('mode-modeLeet').checked = curSettings.modeLeet; document.getElementById('mode-modeHomophone').checked = curSettings.modeHomophone; document.getElementById('mode-modeSimilar').checked = curSettings.modeSimilar; document.getElementById('mode-modeFuzzy').checked = curSettings.modeFuzzy; document.getElementById('mode-modeSplit').checked = curSettings.modeSplit; document.getElementById('fuzzy-distance').value = curSettings.maxFuzzyDistance; document.getElementById('fuzzy-distance-value').textContent = curSettings.maxFuzzyDistance; document.getElementById('log-console').checked = curSettings.logToConsole;
overlay.style.display = 'flex'; };
document.body.appendChild(triggerBtn); } }
// ========== 初始化 ========== function init() { processDocument(); createSettingsPanel(); observeMutations(); console.log('【内容净化器】已启动'); }
if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', init); } else { init(); }
// ========== 菜单命令 ========== GM_registerMenuCommand('测试匹配', testMatching); GM_registerMenuCommand('打开设置', () => { document.getElementById('gm-settings-overlay').style.display = 'flex'; });
})();```
::::warning[注意]{open}1. 更新脚本时,请**关闭插件**,否则可能会引发失效等**不应出现**的错误2. 可能会出现误杀等情况,可联系@[WJRAK](https://www.luogu.com.cn/user/1695884)以解决3. 与[洛谷驱猫助手](https://www.luogu.com.cn/article/ora3c5va)同时使用体验更佳。4. 开启高级模式体验更佳!5. 本脚本全浏览器通用哦!::::::::info[效果]{open}原图1: 效果1: 原图2: 效果2: 原图3: 效果3: ::::
::::warning[注意]更新脚本时,请**关闭插件**,否则可能会引发失效等**不应出现**的错误::::