装饰你的洛谷
前言
如果你觉得原洛谷非常普通,哪怕加装了主题也是非常普通。那你可以试一下这个脚本,应该较为简单。其中提供的JavaScript代码提供者Perry6632,我只是详细讲解一下。
具体步骤
这里先提供Microsft edge的方法,因为edge自带的拓展非常方便,你可以到这个地方找到适合你的浏览器的版本(包括edge google firefox safari)
你可以点击这里 以添加拓展。
再打开篡改猴加入界面,大概是这样。
点击那个加号,然后进入一个界面,将那个页面的所有代码删除,然后添加下面这个JavaScript代码
// ==UserScript==
// @name 洛谷pro
// @namespace http://tampermonkey.net/
// @version 2024-08-20
// @description try to take over the world!
// @author perry6632
// @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,1)";
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,1)";
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.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("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 6px 20px 0 rgba(0, 0, 0, 0.19)";
d[i].style.borderRadius="10px";
}
}
d=document.getElementsByClassName("am-btn");
if(d){
for(let i=0;i<d.length;i++){
b[i].style.backgroundColor="rgba(255,255,255,1)";
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');
}
}
document.body.style.background="url(https://cdn.luogu.com.cn/upload/image_hosting/46ufsk8q.png) fixed";//在这个地方修改网址就行,可以使用洛谷图床等
document.body.style.backgroundSize="cover";
var f=document.getElementsByClassName("container");
if(f){
for(let i=0;i<f.length;i++){
f[i].style.maxWidth="1080px";
f[i].style.marginTop="15px";
f[i].style.backgroundColor="rgba(255,255,255,1)";
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()
})();
最后使用Ctrl+S保存,打开洛谷就行了。
目前修复了触碰到某些栏目会不正常放大 上方标签栏背景色过暗会掩盖的BUG,当然,你完全可以使用氢洛谷,不过鉴于我朋友的审美问题(我也觉得确实有点花里胡哨),这是对氢洛谷的简化版本。
Tips
如果没加载出来,可以检查一下,代码是否有问题。可以找Perry6632反馈BUG
展示图
7rhj764