版本比较
洛谷灌水清理器
标题
增加 1 行删除 1 行
1洛谷灌水清理器 1.01洛谷灌水清理器
正文
增加 537 行删除 212 行
12345678910111213141516174 行未改动2223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451466 行未改动1531541551561571581591601611621631641651661671681691703 行未改动1741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483498 行未改动3583593603613623633643653663673682 行未改动3713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084093 行未改动413414415416417418419420421422423424425426427428429430431432433434435436437438439# 准备工作首先,你需要安装 [Microsoft Edge 浏览器](https://lds.10284.com/lds/edge.html?wordId=1230534802983&userid=72381821&bd_vid=11774409941675733672)或 [夸克浏览器](https://b.quark.cn/apps/qkhomepage_twofoufeb/routes/model?entry=sem_ztbdsempckk_brand_23&ch=sem_ztbdsempckk_brand_23&image=career2024&dp=&planid=624046343&unitid=10401599032&a_keywordid=889687556079&a_creative=115111313928&a_matchtype=2&a_dongtai=0&a_keyword=%E5%AE%98%E6%96%B9%E5%A4%B8%E5%85%8B%E6%B5%8F%E8%A7%88%E5%99%A8%E5%A4%B8%E5%85%8B&from=bdsem&bd_vid=11454525102374689210)。然后,安装[暴力猴](https://microsoftedge.microsoft.com/addons/detail/%E6%9A%B4%E5%8A%9B%E7%8C%B4/eeagobfjdenkkddmbclomhiblgggliao?hl=zh-CN).# 源码```// ==UserScript==// @name 洛谷综合清理器// @namespace http://tampermonkey.net/// @version 1.0// @description 综合删除洛谷的犇犇、铃铛、私信、讨论等元素// @match http://www.luogu.com.cn/*// @match https://www.luogu.com.cn/*// @author Sweet_2013// @grant none4 行未改动'use strict';console.log('洛谷综合清理器启动');// 配置:所有要删除的元素选择器const removalConfig = {// 通知铃铛bell: ['a[href="/user/notification"]','svg[data-icon="bell"]','path[d*="M224 0c-17.7"]','.fa-bell'],// 私信/邮件message: ['a[href="/chat"]','svg[data-icon="envelope"]','path[d*="M48 64C21.5"]','.fa-envelope'],// 应用按钮app: ['.popup-button','svg[data-icon="angles-right"]'],// 讨论 - 只删除顶部的讨论链接discuss: ['a[href="/discuss"]','svg[data-icon="comments"]','path[d*="M208 352c114.9"]'],// 犇犇相关 - 只在首页删除feed: ['#feed-content','#feed-submit','#emo-lst','.exlg-emo-btn','.feed-selector','#home-center-nav'],// 用户信息user: ['a[href*="/following"]','a[href*="/follower"]'],// 设置相关settings: ['#LRadio-1','#LRadio-2']};// 检查是否在编辑器页面function isEditorPage() {return window.location.href.includes('/article/edit') ||window.location.href.includes('/blog/edit') ||document.querySelector('.editor-container') ||document.querySelector('.markdown-editor') ||document.querySelector('[class*="editor"]') ||document.querySelector('#title') && document.querySelector('#content');}// 检查是否在专栏页面function isArticlePage() {return window.location.href.includes('/article/') ||window.location.href.includes('/blog/') ||document.querySelector('.article-content') ||document.querySelector('.blog-content');}// 安全删除函数function safeRemoveElements() {// 如果在编辑器或专栏页面,不执行删除if (isEditorPage() || isArticlePage()) {console.log('在编辑器或专栏页面,跳过删除');return;}console.log('开始安全清理...');// 1. 按选择器删除,但只在特定区域操作Object.values(removalConfig).flat().forEach(selector => {try {document.querySelectorAll(selector).forEach(element => {if (element && element.parentNode) {// 检查元素是否在安全删除区域const isSafeToRemove = isInSafeRemovalArea(element);if (isSafeToRemove) {console.log('安全删除元素:', selector, element);element.remove();}}});} catch (e) {// 忽略选择器错误}});// 2. 按文本内容删除,但更精确safeRemoveByTextContent();// 3. 精确区域删除removeSpecificAreas();}// 检查元素是否在安全删除区域function isInSafeRemovalArea(element) {// 安全删除区域:导航栏、头部、设置页面、首页特定区域const safeAreas = ['header', '.header', 'nav', '.nav','.icon-btn', '.popup-button','.l-form-layout', // 设置区域'#app > div > div > div', // 首页主要内容区'.main-container'];// 检查元素是否在安全区域for (let area of safeAreas) {6 行未改动const safeIds = ['feed-content', 'feed-submit', 'emo-lst', 'home-center-nav','LRadio-1', 'LRadio-2'];if (element.id && safeIds.includes(element.id)) {return true;}// 检查是否在危险区域(编辑器、文章内容等)const dangerAreas = ['.editor-container', '.markdown-editor', '[class*="editor"]','.article-content', '.blog-content', '.content-area','.code-editor', '.w-md-editor'];for (let area of dangerAreas) {if (element.closest(area)) {3 行未改动return false;}// 安全的文本内容删除function safeRemoveByTextContent() {const textTargets = [{ text: '有什么新鲜事告诉大家', container: '.lg-article', area: 'home' },{ text: '发射犇犇', container: '.lg-article', area: 'home' },{ text: '动态', container: '.entry', area: 'nav' },{ text: '学术模式', container: '.l-form-layout', area: 'settings' },{ text: '权限变更记录', container: '.l-form-layout', area: 'settings' },{ text: '讨论', container: null, area: 'nav' }];textTargets.forEach(({text, container, area}) => {try {const walker = document.createTreeWalker(document.body,NodeFilter.SHOW_TEXT,null,false);let node;const nodesToRemove = [];while (node = walker.nextNode()) {if (node.textContent.includes(text)) {const element = node.parentElement;// 检查是否在安全区域if (isInSafeTextRemovalArea(element, area)) {if (container) {const containerEl = element.closest(container);if (containerEl && isInSafeRemovalArea(containerEl)) {nodesToRemove.push(containerEl);}} else {nodesToRemove.push(element);}}}}// 删除找到的元素nodesToRemove.forEach(element => {if (element && element.parentNode) {console.log('安全文本删除:', text, element);element.remove();}});} catch (e) {console.log('文本删除错误:', e);}});}// 检查文本是否在安全删除区域function isInSafeTextRemovalArea(element, areaType) {switch(areaType) {case 'nav':return element.closest('header') ||element.closest('.header') ||element.closest('nav');case 'home':return window.location.pathname === '/' ||window.location.pathname === '/index' ||element.closest('#app > div > div > div');case 'settings':return window.location.href.includes('/user/setting') ||element.closest('.l-form-layout');default:return isInSafeRemovalArea(element);}}// 精确区域删除function removeSpecificAreas() {// 只在首页删除犇犇区域if (window.location.pathname === '/' || window.location.pathname === '/index') {const articles = document.querySelectorAll('.lg-article');articles.forEach(article => {const text = article.textContent;if ((text.includes('有什么新鲜事') || text.includes('发射犇犇')) &&isInSafeRemovalArea(article)) {console.log('删除犇犇区域:', article);article.remove();}});}// 导航栏图标 - 只在导航栏内删除const navItems = document.querySelectorAll('.icon-btn, [class*="btn"], [class*="button"]');navItems.forEach(item => {const isInNav = item.closest('header') ||item.closest('.header') ||item.closest('nav');if (isInNav && isInSafeRemovalArea(item)) {const html = item.innerHTML;if (html.includes('bell') ||html.includes('envelope') ||html.includes('M224 0c-17.7') ||html.includes('M48 64C21.5')) {console.log('删除导航项:', item);item.remove();}}});// 设置区域 - 只在设置页面删除if (window.location.href.includes('/user/setting')) {const layouts = document.querySelectorAll('.l-form-layout');layouts.forEach(layout => {const text = layout.textContent;if ((text.includes('学术模式') || text.includes('权限变更记录')) &&isInSafeRemovalArea(layout)) {console.log('删除设置区域:', layout);layout.remove();}});}// 动态入口const entries = document.querySelectorAll('.entry');entries.forEach(entry => {if (entry.textContent.includes('动态') && isInSafeRemovalArea(entry)) {console.log('删除动态入口:', entry);entry.remove();}});// 关注粉丝统计const statTexts = document.querySelectorAll('.stat-text.name');statTexts.forEach(stat => {if ((stat.textContent.includes('关注') || stat.textContent.includes('粉丝')) &&isInSafeRemovalArea(stat)) {console.log('删除统计信息:', stat);const field = stat.closest('.field');if (field && isInSafeRemovalArea(field)) {field.remove();}}});}// 智能监控函数function startIntelligentMonitoring() {let removalCount = 0;const maxRemovals = 100;function smartRemove() {if (removalCount >= maxRemovals) {console.log('达到最大删除次数,停止监控');return;}removalCount++;safeRemoveElements();// 只在非编辑器页面检查if (!isEditorPage() && !isArticlePage()) {const hasTargets =document.querySelector('header a[href="/user/notification"]') ||document.querySelector('header a[href="/chat"]') ||document.querySelector('header a[href="/discuss"]') ||(window.location.pathname === '/' && document.querySelector('#feed-content'));if (hasTargets) {console.log('检测到残留元素,继续清理');setTimeout(smartRemove, 500);} else {console.log('所有目标元素已清理完成');}}8 行未改动} else {startIntelligentMonitoring();}// 高级MutationObserverconst observer = new MutationObserver((mutations) => {// 如果在编辑器或专栏页面,不执行删除if (isEditorPage() || isArticlePage()) {return;}2 行未改动mutations.forEach((mutation) => {if (mutation.addedNodes.length) {mutation.addedNodes.forEach((node) => {if (node.nodeType === 1) {// 只在安全区域检查新增元素const isInNav = node.closest && (node.closest('header') ||node.closest('.header') ||node.closest('nav'));if (isInNav && node.querySelector && (node.querySelector('a[href="/user/notification"]') ||node.querySelector('a[href="/chat"]') ||node.querySelector('a[href="/discuss"]') ||(window.location.pathname === '/' && node.querySelector('#feed-content')))) {shouldRemove = true;}// 检查元素本身if (node.href === '/user/notification' ||node.href === '/chat' ||node.href === '/discuss' ||(window.location.pathname === '/' && node.id === 'feed-content')) {shouldRemove = true;}}});}});if (shouldRemove) {console.log('检测到动态添加的目标元素');setTimeout(safeRemoveElements, 100);}});// 开始观察3 行未改动attributes: true,attributeFilter: ['href', 'id', 'class']});// 页面加载完成后的深度清理window.addEventListener('load', () => {setTimeout(() => {console.log('页面加载完成,执行安全清理');safeRemoveElements();}, 3000);});// 定期维护清理(只在非编辑器页面)setInterval(() => {if (!isEditorPage() && !isArticlePage()) {safeRemoveElements();}}, 15000);console.log('洛谷综合清理器安全版初始化完成');})();```# 致谢感谢 [Sweet_2013](http://www.luogu.com.cn/user.1570347) ,她调戏了 Deepseek 17 遍完成了该插件的创作。(bushi也感谢 Deepseek 连续十六次对着 Sweet_2013 道歉并一次次改版。12345678910111213141516171819202122232425264 行未改动3132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895906 行未改动5975985996006016026036046056066076086096106116126136146156166176186196206213 行未改动6256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686698 行未改动6786796806816826836846856866872 行未改动6906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377383 行未改动742743744745746747748749750751752753754755756757758759760761762763764# 准备工作首先,你需要安装 [Microsoft Edge 浏览器](https://lds.10284.com/lds/edge.html?wordId=1230534802983&userid=72381821&bd_vid=11774409941675733672)或 [夸克浏览器](https://b.quark.cn/apps/qkhomepage_twofoufeb/routes/model?entry=sem_ztbdsempckk_brand_23&ch=sem_ztbdsempckk_brand_23&image=career2024&dp=&planid=624046343&unitid=10401599032&a_keywordid=889687556079&a_creative=115111313928&a_matchtype=2&a_dongtai=0&a_keyword=%E5%AE%98%E6%96%B9%E5%A4%B8%E5%85%8B%E6%B5%8F%E8%A7%88%E5%99%A8%E5%A4%B8%E5%85%8B&from=bdsem&bd_vid=11454525102374689210)。然后,安装[暴力猴](https://microsoftedge.microsoft.com/addons/detail/%E6%9A%B4%E5%8A%9B%E7%8C%B4/eeagobfjdenkkddmbclomhiblgggliao?hl=zh-CN).# 该插件能够实现的功能- 隐藏主页讨论区- 隐藏主页犇犇(不管开没开学术模式都发不了犇犇)- 隐藏权限更变记录- 隐藏能够设置学术模式的开关- 隐藏主页的关注、粉丝- 隐藏左侧栏的应用- 隐藏左侧栏的讨论区- 隐藏右上角的私信+铃铛# 源码```// ==UserScript==// @name 洛谷综合清理器// @namespace http://tampermonkey.net/// @version 1.0// @description 综合删除洛谷的犇犇、铃铛、私信、讨论等元素,保护重要功能// @match http://www.luogu.com.cn/*// @match https://www.luogu.com.cn/*// @author Sweet_2013// @grant none4 行未改动'use strict';console.log('洛谷综合清理器启动');// 配置:父容器选择器,直接删除整个父容器const parentContainerConfig = {// 通知铃铛 - 删除整个图标按钮容器bell: ['a[href="/user/notification"]','svg[data-icon="bell"]','.icon-btn[href*="notification"]'],// 私信/邮件 - 删除整个图标按钮容器message: ['a[href="/chat"]','svg[data-icon="envelope"]','.icon-btn[href*="chat"]'],// 应用按钮 - 删除整个弹出按钮容器app: ['.popup-button','svg[data-icon="angles-right"]'],// 讨论 - 删除整个讨论链接容器discuss: ['a[href="/discuss"]','svg[data-icon="comments"]','.icon-btn[href*="discuss"]','a[href="/discuss"] .text' // 新增:讨论文本],// 犇犇相关 - 直接删除整个犇犇容器feed: ['#feed-content','#feed-submit','#emo-lst','.feed-selector','.feed-item', // 新增:犇犇项'[class*="feed"]' // 新增:所有包含feed的类],// 用户信息 - 只删除关注和粉丝,保护提交数和通过数user: ['a[href*="/following"]','a[href*="/follower"]'],// 设置相关 - 删除学术模式和权限记录settings: ['#LRadio-1','#LRadio-2'],// 个人主页白色栏 - 关注和动态profileTabs: ['a[href*="following"]','a[href*="follower"]','.item[href*="feed"]','.tab[href*="feed"]']};// 配置:需要保护的重要元素const protectedConfig = {// 用户统计数据 - 保护提交数和通过数userStats: ['[class*="score"]', // 等级分'[class*="accepted"]', // 通过数'[class*="pass"]', // 通过率'[class*="rank"]', // 排名'[class*="submit"]' // 提交数 - 现在保护提交数],// 左侧栏重要功能sidebarFunctions: ['a[href="/"]', // 回到主页'a[href*="/problem"]', // 题库'a[href*="/contest"]', // 比赛'a[href*="/training"]', // 训练'a[href*="/record"]', // 评测记录'a[href*="/article"]', // 专栏'a[href*="/blog"]' // 博客],// 题目页面重要信息problemInfo: ['.problem-info', // 题目信息容器'.info-item', // 信息项'.statics', // 统计信息'.data-range', // 数据范围'.memory-limit', // 空间限制'.time-limit', // 时间限制'.sample', // 样例'.input', // 输入'.output', // 输出'.problem-content' // 题目内容]};// 检查是否在编辑器页面function isEditorPage() {return window.location.href.includes('/article/edit') ||window.location.href.includes('/blog/edit') ||document.querySelector('.editor-container') ||document.querySelector('.markdown-editor') ||document.querySelector('[class*="editor"]') ||document.querySelector('#title') && document.querySelector('#content');}// 检查是否在专栏页面function isArticlePage() {return window.location.href.includes('/article/') ||window.location.href.includes('/blog/') ||document.querySelector('.article-content') ||document.querySelector('.blog-content');}// 检查是否在题目页面function isProblemPage() {return window.location.href.includes('/problem/') ||document.querySelector('.problem-content') ||document.querySelector('.problem-info') ||document.querySelector('.sample-container');}// 检查是否在个人主页function isUserProfilePage() {return window.location.pathname.match(/^\/user\/\d+$/);}// 检查元素是否需要保护function isProtectedElement(element) {// 如果在题目页面,保护所有题目相关元素if (isProblemPage()) {const problemSelectors = protectedConfig.problemInfo.flat();for (let selector of problemSelectors) {if (element.matches(selector) || element.closest(selector)) {return true;}}// 检查是否在题目内容区域内if (element.closest('.problem-content') ||element.closest('.sample-container') ||element.closest('.problem-sidebar')) {return true;}}// 检查用户统计数据const userStatsSelectors = protectedConfig.userStats.flat();for (let selector of userStatsSelectors) {if (element.matches(selector) || element.closest(selector)) {return true;}}// 检查左侧栏重要功能const sidebarSelectors = protectedConfig.sidebarFunctions.flat();for (let selector of sidebarSelectors) {if (element.matches(selector) || element.closest(selector)) {return true;}}// 检查文本内容是否包含重要功能const text = element.textContent || '';const protectedTexts = ['提交数', '通过数', '等级分', '通过率', '排名','题库', '题目', '比赛', '训练','专栏', '博客', '评测记录', '记录','主页', '首页','时间限制', '空间限制', '内存限制', '数据范围','输入', '输出', '样例', '题目描述'];for (let protectedText of protectedTexts) {if (text.includes(protectedText)) {return true;}}return false;}// 获取父容器function getParentContainer(element) {// 优先查找常见的父容器类型const parentContainers = [element.closest('.icon-btn'), // 图标按钮element.closest('.entry'), // 导航项element.closest('.card'), // 卡片element.closest('.am-panel'), // 面板element.closest('.panel'), // 面板element.closest('.l-form-layout'), // 设置布局element.closest('.field'), // 字段容器element.closest('.lg-article'), // 文章容器element.closest('section'), // 区域element.closest('li'), // 列表项element.closest('.nav-item'), // 导航项element.closest('.btn-group'), // 按钮组element.parentElement // 直接父元素];for (let container of parentContainers) {if (container && container !== document.body) {// 检查父容器是否需要保护if (!isProtectedElement(container)) {return container;}}}return element.parentElement;}// 批量删除父容器function removeParentContainers() {// 如果在编辑器或专栏页面,不执行删除if (isEditorPage() || isArticlePage()) {console.log('在编辑器或专栏页面,跳过删除');return;}console.log('开始批量删除父容器...');let removedCount = 0;// 遍历所有配置的选择器Object.values(parentContainerConfig).flat().forEach(selector => {try {document.querySelectorAll(selector).forEach(element => {if (element && element.parentNode) {// 检查元素是否在安全删除区域且不需要保护if (isInSafeRemovalArea(element) && !isProtectedElement(element)) {const parentContainer = getParentContainer(element);if (parentContainer && parentContainer.parentNode && !isProtectedElement(parentContainer)) {console.log('删除父容器:', selector, parentContainer);parentContainer.remove();removedCount++;}}}});} catch (e) {// 忽略选择器错误}});console.log(`本次删除了 ${removedCount} 个父容器`);// 特殊处理:删除整个犇犇区域(包括别人的犇犇)removeFeedAreaCompletely();// 特殊处理:彻底删除讨论区域removeDiscussionAreaCompletely();// 特殊处理:删除设置项(学术模式和权限记录)removeSettingsItems();// 特殊处理:删除个人主页白色栏的关注和动态removeProfileTabs();// 特殊处理:删除左侧栏讨论链接removeSidebarDiscussion();// 特殊处理:删除讨论文本链接removeDiscussionTextLinks();// 特殊处理:删除权限变更记录removePermissionChangeRecord();}// 彻底删除犇犇区域(包括别人的犇犇)function removeFeedAreaCompletely() {if (window.location.pathname === '/' || window.location.pathname === '/index') {console.log('开始彻底删除犇犇区域...');// 方法1: 删除所有犇犇相关容器const feedContainers = [document.querySelector('#feed-content'),document.querySelector('.lg-article'),document.querySelector('[class*="feed"]')];feedContainers.forEach(container => {if (container && isInSafeRemovalArea(container) && !isProtectedElement(container)) {console.log('删除犇犇容器:', container);container.remove();}});// 方法2: 删除所有犇犇项const feedItems = document.querySelectorAll('.feed-item, [class*="feed"]');feedItems.forEach(item => {if (item && isInSafeRemovalArea(item) && !isProtectedElement(item)) {console.log('删除犇犇项:', item);item.remove();}});// 方法3: 通过文本内容识别犇犇document.querySelectorAll('div, section, article').forEach(element => {if (element && element.parentNode && isInSafeRemovalArea(element) && !isProtectedElement(element)) {const text = element.textContent || '';if (text.includes('犇犇') || text.includes('新鲜事') ||text.includes('发射') || (text.includes('@') && text.includes(':'))) {console.log('通过文本识别删除犇犇:', element);element.remove();}}});}}// 彻底删除讨论区域function removeDiscussionAreaCompletely() {// 只在首页删除讨论版if (window.location.pathname === '/' || window.location.pathname === '/index') {console.log('开始彻底删除讨论区域...');// 方法1: 删除包含"最近讨论"标题的整个容器const discussionTitles = document.querySelectorAll('h2, h3, .title, .header');discussionTitles.forEach(title => {if (title && title.textContent.includes('最近讨论')) {const container = title.closest('.lg-article') ||title.closest('.card') ||title.closest('.am-panel') ||title.closest('section') ||title.parentElement;if (container && isInSafeRemovalArea(container) && !isProtectedElement(container)) {console.log('删除讨论标题容器:', container);container.remove();}}});// 方法2: 删除所有讨论帖子const discussionPosts = document.querySelectorAll('.am-panel, section, .lg-index-contest');discussionPosts.forEach(post => {if (post && isInSafeRemovalArea(post) && !isProtectedElement(post)) {const text = post.textContent || '';const html = post.innerHTML || '';// 检查是否是讨论帖子if (text.includes('回复') || text.includes('讨论') ||html.includes('/discuss/') || html.includes('lg-index-contest')) {console.log('删除讨论帖子:', post);post.remove();}}});// 方法3: 删除整个讨论区域容器const discussionContainers = document.querySelectorAll('.lg-article');discussionContainers.forEach(container => {if (container && isInSafeRemovalArea(container) && !isProtectedElement(container)) {const text = container.textContent || '';if (text.includes('最近讨论') || text.includes('讨论区')) {console.log('删除整个讨论区域:', container);container.remove();}}});}}// 删除设置项(学术模式和权限记录)function removeSettingsItems() {if (window.location.href.includes('/user/setting')) {// 查找所有设置项const settingsItems = document.querySelectorAll('.l-form-layout, .setting-item, .form-item, [class*="radio"]');settingsItems.forEach(item => {if (item && item.parentNode && isInSafeRemovalArea(item) && !isProtectedElement(item)) {const text = item.textContent || '';// 删除学术模式if (text.includes('学术模式') || text.includes('学术模式开关')) {console.log('删除学术模式设置:', item);item.remove();}}});}}// 删除权限变更记录function removePermissionChangeRecord() {if (window.location.href.includes('/user/setting')) {console.log('开始删除权限变更记录...');// 方法1: 直接查找包含"权限变更记录"文本的span元素,然后删除其父容器const permissionSpans = document.querySelectorAll('span');permissionSpans.forEach(span => {if (span.textContent === '权限变更记录') {const container = span.closest('.l-form-layout');if (container && container.parentNode) {console.log('找到权限变更记录容器,准备删除:', container);container.remove();console.log('权限变更记录已删除');}}});// 方法2: 如果方法1失败,使用更精确的选择器const permissionContainers = document.querySelectorAll('.l-form-layout');permissionContainers.forEach(container => {if (container && container.parentNode) {const span = container.querySelector('span');if (span && span.textContent === '权限变更记录') {console.log('通过精确选择器找到权限变更记录容器:', container);container.remove();console.log('权限变更记录已删除');}}});// 方法3: 使用TreeWalker确保找到所有实例const walker = document.createTreeWalker(document.body,NodeFilter.SHOW_TEXT,null,false);let node;while (node = walker.nextNode()) {if (node.textContent.trim() === '权限变更记录') {const span = node.parentElement;if (span && span.tagName === 'SPAN') {const container = span.closest('.l-form-layout');if (container && container.parentNode) {console.log('通过TreeWalker找到权限变更记录容器:', container);container.remove();console.log('权限变更记录已删除');break; // 删除一个就足够}}}}// 方法4: 强制删除 - 查找所有包含权限变更记录文本的.l-form-layoutconst allLayouts = document.querySelectorAll('.l-form-layout');allLayouts.forEach(layout => {if (layout && layout.parentNode) {const text = layout.textContent || '';if (text.includes('权限变更记录') &&text.includes('时间') &&text.includes('原因') &&text.includes('权限变更')) {console.log('通过文本特征找到权限变更记录容器:', layout);layout.remove();console.log('权限变更记录已删除');}}});}}// 删除个人主页白色栏的关注和动态function removeProfileTabs() {if (isUserProfilePage()) {// 查找白色栏容器const profileNav = document.querySelector('.user-nav, .profile-nav, .tabs, [class*="tab"], [class*="nav"]');if (profileNav) {// 删除关注和动态标签const tabsToRemove = profileNav.querySelectorAll('a, .item, .tab, li');tabsToRemove.forEach(tab => {if (tab && tab.parentNode) {const text = tab.textContent || '';const href = tab.getAttribute('href') || '';if (text.includes('关注') || text.includes('粉丝') ||text.includes('动态') || text.includes('Feed') ||href.includes('following') || href.includes('follower') ||href.includes('feed')) {console.log('删除个人主页标签:', text, tab);tab.remove();}}});}// 额外查找:直接通过文本内容删除document.querySelectorAll('a, .item, .tab').forEach(element => {if (element && element.parentNode && isInSafeRemovalArea(element) && !isProtectedElement(element)) {const text = element.textContent || '';if ((text.includes('关注') || text.includes('动态')) &&!text.includes('提交数') && !text.includes('通过数')) {console.log('删除个人主页元素:', text, element);element.remove();}}});}}// 删除左侧栏讨论链接function removeSidebarDiscussion() {// 查找左侧栏容器const sidebar = document.querySelector('.sidebar, .left, [class*="sidebar"], [class*="left"]');if (!sidebar) return;// 在左侧栏中删除讨论链接const sidebarItems = sidebar.querySelectorAll('a, .item, .nav-item, li');sidebarItems.forEach(item => {if (item && item.parentNode) {const text = item.textContent || '';const href = item.getAttribute('href') || '';// 删除讨论相关if (text.includes('讨论') || text.includes('Discuss') ||href === '/discuss' || href.includes('/discuss/') ||item.querySelector('svg[data-icon="comments"]')) {console.log('删除左侧栏讨论:', item);// 删除整个列表项,避免留下空白const listItem = item.closest('li') || item;listItem.remove();}}});}// 删除讨论文本链接function removeDiscussionTextLinks() {// 查找所有包含"讨论"文本的链接const discussionLinks = document.querySelectorAll('a');discussionLinks.forEach(link => {if (link && link.parentNode && isInSafeRemovalArea(link) && !isProtectedElement(link)) {const text = link.textContent || '';const href = link.getAttribute('href') || '';if ((text.trim() === '讨论' || href === '/discuss') &&!text.includes('提交数') && !text.includes('通过数')) {console.log('删除讨论文本链接:', link);// 删除整个链接的父容器,避免留下空白const container = link.closest('li') || link.closest('.item') || link;container.remove();}}});}// 检查元素是否在安全删除区域function isInSafeRemovalArea(element) {// 安全删除区域:导航栏、头部、设置页面、首页特定区域、个人主页白色栏const safeAreas = ['header', '.header', 'nav', '.nav','.icon-btn', '.popup-button','.l-form-layout', // 设置区域'#app > div > div > div', // 首页主要内容区'.main-container','.user-nav', '.profile-nav', '.tabs', // 个人主页导航栏'.sidebar', '.left' // 左侧栏];// 检查元素是否在安全区域for (let area of safeAreas) {6 行未改动const safeIds = ['feed-content', 'feed-submit', 'emo-lst', 'home-center-nav','LRadio-1', 'LRadio-2'];if (element.id && safeIds.includes(element.id)) {return true;}// 检查是否在危险区域(编辑器、文章内容、题目页面等)const dangerAreas = ['.editor-container', '.markdown-editor', '[class*="editor"]','.article-content', '.blog-content', '.content-area','.code-editor', '.w-md-editor','.problem-content', // 题目内容'.sample-container', // 样例容器'.problem-list', // 题目列表'.practice-plan', // 练习计划'.training-container', // 训练容器'.problem-info', // 题目信息'.info-item' // 信息项];for (let area of dangerAreas) {if (element.closest(area)) {3 行未改动return false;}// 智能监控函数function startIntelligentMonitoring() {let removalCount = 0;const maxRemovals = 15;function smartRemove() {if (removalCount >= maxRemovals) {console.log('达到最大删除次数,停止监控');return;}removalCount++;removeParentContainers();// 只在非编辑器页面检查if (!isEditorPage() && !isArticlePage()) {const hasTargets =document.querySelector('header a[href="/user/notification"]') ||document.querySelector('header a[href="/chat"]') ||document.querySelector('a[href="/discuss"]') ||document.querySelector('a .text') && document.querySelector('a .text').textContent.includes('讨论') ||(window.location.pathname === '/' &&(document.querySelector('#feed-content') ||document.querySelector('.lg-article') ||document.querySelector('[class*="feed"]') ||document.querySelector('h2') && document.querySelector('h2').textContent.includes('最近讨论'))) ||(window.location.href.includes('/user/setting') &&(document.querySelector('.l-form-layout') ||document.querySelector('*').textContent.includes('权限变更记录'))) ||(isUserProfilePage() &&(document.querySelector('a[href*="following"]') ||document.querySelector('a[href*="follower"]') ||document.querySelector('a[href*="feed"]')));if (hasTargets) {console.log('检测到残留元素,继续清理');setTimeout(smartRemove, 300);} else {console.log('所有目标元素已清理完成');}}8 行未改动} else {startIntelligentMonitoring();}// 监听动态加载的内容const observer = new MutationObserver((mutations) => {if (isEditorPage() || isArticlePage()) {return;}2 行未改动mutations.forEach((mutation) => {if (mutation.addedNodes.length) {mutation.addedNodes.forEach((node) => {if (node.nodeType === 1) {// 检查是否添加了目标元素if (node.querySelector && (node.querySelector('a[href="/user/notification"]') ||node.querySelector('a[href="/chat"]') ||node.querySelector('a[href="/discuss"]') ||node.querySelector('#feed-content') ||node.querySelector('.popup-button') ||node.querySelector('a[href*="following"]') ||node.querySelector('a[href*="follower"]') ||node.querySelector('a[href*="feed"]') ||node.querySelector('.lg-article') ||node.querySelector('h2') ||node.querySelector('a .text') ||node.textContent.includes('权限变更记录'))) {shouldRemove = true;}// 检查元素本身if (node.href === '/user/notification' ||node.href === '/chat' ||node.href === '/discuss' ||node.id === 'feed-content' ||node.classList.contains('popup-button') ||(node.href && (node.href.includes('following') ||node.href.includes('follower') ||node.href.includes('feed'))) ||node.classList.contains('lg-article') ||(node.tagName === 'H2' && node.textContent.includes('最近讨论')) ||(node.classList.contains('text') && node.textContent.includes('讨论')) ||node.textContent.includes('权限变更记录')) {shouldRemove = true;}}});}});if (shouldRemove) {console.log('检测到动态添加的目标元素');setTimeout(removeParentContainers, 100);}});// 开始观察3 行未改动attributes: true,attributeFilter: ['href', 'id', 'class']});// 页面加载完成后的清理window.addEventListener('load', () => {setTimeout(() => {console.log('页面加载完成,执行最终清理');removeParentContainers();}, 2000);});// 定期维护清理(只在非编辑器页面)setInterval(() => {if (!isEditorPage() && !isArticlePage()) {removeParentContainers();}}, 10000);console.log('洛谷综合清理器保护版初始化完成');})();```