跳到正文

个人记录

洛谷proV2.0

枫原万叶约 13 分钟
原文
文章信息与版本

文章信息

发布
2025年2月7日
收录
2025年12月12日
更新
2026年11月14日
篇幅
约 13 分钟

版本

  1. v1当前

对于洛谷pro的某一些问题,我们做出了一些改进,例如:

洛谷主页 用户主页 私信页面 的 container 类长度不匹配的问题。

洛谷的各个板块可以调节透明度。

如果有更多的改进意见欢迎在该文章留言。V1.0安装

JS脚本:

JavaScript
// ==UserScript==
// @name         洛谷pro
// @namespace    http://tampermonkey.net/
// @version      2024-08-20
// @description  try to take over the world!
// @author       perry6632&Easoncalm
// @match        https://www.luogu.com.cn/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=cnblogs.com
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    var fn = function() {
        var a = document.querySelector('.footer');
        if (a) {
            a.parentNode.removeChild(a);
        }
        var b = document.getElementsByClassName("lg-article");
        if (b) {
            for (let i = 0; i < b.length; i++) {
                b[i].style.backgroundColor = "rgba(255,255,255,0.8)"; // 设置透明度
                b[i].style.boxShadow = "0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19)";
                b[i].style.borderRadius = "10px";
            }
        }
        var d = document.getElementsByClassName("card");
        if (d) {
            for (let i = 0; i < d.length; i++) {
                d[i].style.backgroundColor = "rgba(255,255,255,0.8)"; // 设置透明度
                d[i].style.boxShadow = "0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19)";
                d[i].style.borderRadius = "10px";
            }
        }
        d = document.getElementsByClassName("am-panel");
        if (d) {
            for (let i = 0; i < d.length; i++) {
                d[i].style.borderStyle = "none";
                d[i].style.backgroundColor = "rgba(255,255,255,0.8)"; // 设置透明度
                d[i].style.boxShadow = "0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19)";
                d[i].style.borderRadius = "10px";
            }
        }
        d = document.getElementsByClassName("wrapper");
        if (d) {
            for (let i = 0; i < d.length; i++) {
                d[i].style.borderStyle = "none";
                d[i].style.backgroundColor = "rgba(255,255,255,0.8)"; // 设置透明度
                d[i].style.boxShadow = "0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19)";
                d[i].style.borderRadius = "10px";
            }
        }
        //language-cpp
        d = document.getElementsByClassName("language-cpp");
        if (d) {
            for (let i = 0; i < d.length; i++) {
                d[i].style.borderRadius = "10px";
            }
        }
        d = document.getElementsByClassName("test-case");
        if (d) {
            for (let i = 0; i < d.length; i++) {
                d[i].style.boxShadow = "0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 3px 20px 0 rgba(0, 0, 0, 0.19)";
                d[i].style.borderRadius = "8px";
            }
        }
        d = document.getElementsByClassName("am-btn");
        if (d) {
            for (let i = 0; i < d.length; i++) {
                //d[i].style.backgroundColor = "rgba(255,255,255,0.8)";
                d[i].style.boxShadow = "0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19)";
                d[i].style.borderRadius = "10px";
            }
        }
        var e = document.getElementsByClassName("background");
        if (e) {
            for (let i = 0; i < e.length; i++) {
                e[i].style.background = "rgba(0,0,0,0)";
            }
        }
        e = document.getElementsByClassName("lfe-body mobile-body");
        if (e) {
            for (let i = 0; i < e.length; i++) {
                e[i].style.backgroundColor = "rgba(0,0,0,0)";
            }
        }
        e = document.getElementsByClassName("header-layout");
        if (e) {
            for (let i = 0; i < e.length; i++) {
                e[i].setAttribute('style', 'background : rgba(0,0,0,0) !important');
            }
        }
        e = document.getElementsByClassName("inner-card");
        if (e) {
            for (let i = 0; i < e.length; i++) {
                e[i].setAttribute('style', 'background : rgba(0,0,0,0) !important');
            }
        }
        e = document.getElementsByClassName("bottom float-bottom");
        if (e) {
            for (let i = 0; i < e.length; i++) {
                e[i].style.backgroundColor = "rgba(255,255,255,0.8)";
                e[i].setAttribute('style', 'background : rgba(0,0,0,0) !important');
            }
        }
        document.body.style.background = "url(https://cdn.luogu.com.cn/upload/image_hosting/cpw0gor3.png) fixed";// 设置背景图
        document.body.style.backgroundSize = "cover";

        var f = document.getElementsByClassName("container");
        if (f) {
            var currentUrl = window.location.href;
            var suffixes = ["main", "activity", "article", "practice", "mine", "mine.team", "mine.contest", "problem", "problem.contest", "problem.training", "following", "following.follower", "following.blacklist", "favorite", "favorite.article"];
            var suffixRegex = suffixes.map(suffix => `#${suffix}`).join('|');
            var regex = new RegExp(`^https://www\\.luogu\\.com\\.cn/user/\\d+(?:${suffixRegex})?$`);

            for (let i = 0; i < f.length; i++) {
                if (regex.test(currentUrl)) {
                    f[i].style.maxWidth = "1170px";
                } else if (currentUrl === "https://www.luogu.com.cn/chat") {
                    f[i].style.maxWidth = "1165px";
                } else {
                    f[i].style.maxWidth = "1080px";
                }
                f[i].style.marginTop = "15px";
                f[i].style.backgroundColor = "rgba(255,255,255,0.8)";
                f[i].style.boxShadow = "0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19)";
                f[i].style.borderRadius = "10px";
            }
        }
        f = document.getElementsByClassName("am-center");
        if (f) {
            for (let i = 0; i < f.length; i++) {
                f[i].style.marginTop = "30px";
            }
        }
        f = document.getElementsByClassName("header-logo");
        if (f) {
            for (let i = 0; i < f.length; i++) {
                f[i].style.width = "80px";
                f[i].style.height = "40px";
            }
        }

        setTimeout(fn, 10);
    };
    fn();
})();

2025-02-07

原文