跳到正文

个人记录

洛谷负优化插件

Moonlighthuanxiyun约 2 分钟
原文
文章信息与版本

文章信息

发布
2026年8月28日
收录
2026年10月9日
更新
2026年11月19日
篇幅
约 2 分钟
获赞
1

版本

  1. v1当前
JavaScript
// ==UserScript==
// @name         洛谷页面精简助手
// @namespace    http://tampermonkey.net/
// @version      2.1
// @description  自动删除洛谷的冗余模块
// @author       Moonlighthuanxiyun
// @match        https://www.luogu.com.cn/problem/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    function cleanPage() {
        const topBar = document.querySelector('div.top-bar');
        if (topBar) topBar.remove();
        const headerLayout = document.querySelector('div.columna-content-wrap.header-layout');
        if (headerLayout) headerLayout.remove();
        const lCards = document.querySelectorAll('div.l-card');
        lCards.forEach(card => {
            if (!card.classList.contains('problem')) {
                card.remove();
            }
        });
    }
    cleanPage();
    const observer = new MutationObserver(() => {
        cleanPage();
    });
    observer.observe(document.body, {
        childList: true,
        subtree: true
    });

})();
原文