// ==UserScript==
// @name 洛谷使用体验优化合集
// @namespace https://www.qqzhi.cc/
// @version 2024.11.18.20
// @description 大大优化洛谷使用体验
// @author 旅禾
// @license MIT
// @match *://*/*
// @require https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js
// @grant GM_getValue
// @grant GM_setValue
// @grant GM_deleteValue
// @grant GM_removeValueChangeListener
// @grant GM_addValueChangeListener
// @grant GM_registerMenuCommand
// @downloadURL https://update.greasyfork.icu/scripts/510926/%E6%B4%9B%E8%B0%B7%E4%BD%BF%E7%94%A8%E4%BD%93%E9%AA%8C%E4%BC%98%E5%8C%96%E5%90%88%E9%9B%86.user.js
// @updateURL https://update.greasyfork.icu/scripts/510926/%E6%B4%9B%E8%B0%B7%E4%BD%BF%E7%94%A8%E4%BD%93%E9%AA%8C%E4%BC%98%E5%8C%96%E5%90%88%E9%9B%86.meta.js
// ==/UserScript==
function 移除首页多余元素(){
document.querySelector("#app-old > div.lg-index-content.am-center > div:nth-child(3) > div.am-u-lg-3.am-u-md-4.lg-right > div:nth-child(1)").remove();
//删去本站公告
document.querySelector("#app-old > div.lg-index-content.am-center > div:nth-child(3) > div.am-u-lg-3.am-u-md-4.lg-right > div.lg-article.am-hide-sm").remove();
//删去友情链接
document.querySelector("#app-old > div.lg-index-content.am-center > div:nth-child(1) > div > div > div > div.am-u-md-8").remove();
document.querySelector("#app-old > div.lg-index-content.am-center > div:nth-child(3) > div.am-u-lg-9.am-u-md-8.lg-index-benben.lg-right > div:nth-child(2)").remove();
//删去slider
document.querySelector("#app-old > div.lg-index-content.am-center > div:nth-child(1) > div > div > div > div").className="am-u-md-12 lg-punch am-text-center";
//打卡高度修复
document.querySelector("#app-old > div.lg-index-content.am-center > div:nth-child(3) > div.am-u-lg-3.am-u-md-4.lg-right > div").lastChild.remove();
document.querySelector("#app-old > div.lg-index-content.am-center > div:nth-child(3) > div.am-u-lg-3.am-u-md-4.lg-right > div").lastChild.remove();
document.querySelector("#app-old > div.lg-index-content.am-center > div:nth-child(3) > div.am-u-lg-3.am-u-md-4.lg-right > div").lastChild.remove();
document.querySelector("#app-old > div.lg-index-content.am-center > div:nth-child(3) > div.am-u-lg-3.am-u-md-4.lg-right > div").lastChild.remove();
document.querySelector("#app-old > div.lg-index-content.am-center > div:nth-child(3) > div.am-u-lg-3.am-u-md-4.lg-right > div").lastChild.remove();
document.querySelector("#app-old > div.lg-index-content.am-center > div:nth-child(3) > div.am-u-lg-3.am-u-md-4.lg-right > div").lastChild.remove();
document.querySelector("#app-old > div.lg-index-content.am-center > div:nth-child(3) > div.am-u-lg-3.am-u-md-4.lg-right > div").lastChild.remove();
//删去智能推荐
document.querySelectorAll(".lg-article.lg-index-stat")[0].remove();
//删去题号跳转
document.querySelectorAll(".am-u-md-12")[0].className="am-u-md-4";
//打卡宽度修复
document.querySelectorAll(".am-g")[0].className="";
//合并首排卡片
document.querySelectorAll(".am-u-md-9")[0].className="am-u-md-8";
//适配统计图宽
window.onload=function(){document.querySelectorAll(".lg-article")[1].style.height=document.querySelectorAll(".lg-article")[0].clientHeight+"px"};
document.querySelectorAll(".lg-article")[1].style.display="flex";
document.querySelectorAll(".lg-article")[1].style.alignContent="center";
document.querySelectorAll(".lg-article")[1].style.justifyContent="center";
document.querySelectorAll(".lg-article")[1].style.flexWrap="wrap";
document.querySelectorAll(".lg-article>.am-g")[1].style.height=""
//适配折线图高
}
function 移除用户主页维护提示(){
window.addEventListener('load',function(){
var main = document.getElementsByClassName("card padding-default");
main = main[main.length-1];
var maintenance = main.getElementsByTagName('div')[0];
var introduction = main.getElementsByTagName('div')[1];
if(maintenance.innerText!='系统维护,该内容暂不可见。') return;
maintenance.style.display="none";
introduction.style.display="block";
})
}
function 移除跨域提示(){
if (document.querySelector("h3")&&document.querySelector("h3").innerText=="即将离开洛谷"){
window.location.host="www.luogu.com";
}
}
function 首页自动聚焦搜索栏(){
$(function(){
document.querySelectorAll(".icon.color-none")[0].click();
})
}
function 添加顶栏置顶链接功能(){
$(function(){
var title = $(".link-container");
var state=GM_getValue("user_link")&&true
初始化();
function 重置(){
if (state){
document.querySelector(".link-container").lastChild.remove();
document.querySelector(".link-container").lastChild.remove();
}
document.querySelector(".link-container").lastChild.remove();
document.querySelector(".link-container").lastChild.remove();
state=GM_getValue("user_link")&&true
初始化();
}
function 设置链接(){
var link = prompt("请输入链接地址(为空清除)");
if (!link)
{ GM_deleteValue("user_link_text");GM_deleteValue("user_link");return; }
var text = prompt("请输入链接文字");
GM_setValue("user_link_text", text);
GM_setValue("user_link", link);
}
function 初始化(){
var prelink = GM_getValue("user_link");
var pretext = GM_getValue("user_link_text")
var link = '' + pretext + '';
var button = document.createElement("button");
button.innerText = '编辑';
button.className = 'am-btn am-btn-sm am-btn-primary'
button.addEventListener('click', 设置链接);
var helper = '';
if (prelink){
button.style.marginLeft="2em";
title.append(link, helper);
}
title.append(button, helper);
}
GM_addValueChangeListener(
"user_link",
function (name, old_value, new_value, remote) {
重置()
}
);
});
}
function 洛谷大吉每一天(){
$('document').ready(function(){
var x=document.querySelectorAll(".lg-punch-result");
var y=document.querySelectorAll(".am-u-sm-6");
if(x[0].innerHTML=="§ 大凶 §"){
var sum="宜:出行
一路顺风";
sum+="宜:继续完成WA的题
下一次就可以AC了";
y[0].innerHTML=sum;
}
x[0].innerHTML="§ 大吉 §";
x[0].style="color:#e74c3c!important";
y[1].innerHTML="万事皆宜";
y[1].style="color:rgba(0, 0, 0, .75)!important";
y[1].style="font-weight:bold";
});
}
function 添加用户查找功能(){
$('document').ready(function(){setTimeout(function () {
$sidebar = $('#app-old .lg-index-content .lg-right.am-u-lg-3');
$firstele = $($sidebar.children()[0]);
$finder = $(`