// ==UserScript== // @name 洛谷使用体验优化合集 // @namespace http://tampermonkey.net/ // @version 2024.10.01 // @description 优化洛谷使用体验 // @author 旅禾 // @license MIT // @match *://www.luogu.com.cn/* // @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 // @downloadURL none // ==/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 添加清理系统生成动态功能(){ let uid = document.querySelector(".avatar").parentElement.href.match(/\d+/g)[0] $('.popup-button').click(function () { $('.apps').append('清理犇犇'); $('#bb-del').click(function () { let uid = window._feInjection.currentUser.uid; $.get('https://www.luogu.com.cn/feed/user/' + uid, function (data) { for (let i = 0; ; i += 2) { let cur = $(data)[i]; if (cur.children[1] === undefined) { break; } if (cur.children[1].children[1].children[0].firstChild.toString() !== "[object Text]") { continue; } let id = cur.children[1].children[0].children[0].children[1].dataset.feedId; $.post("/api/feed/delete/" + id); } alert("完成清理,按下确定刷新"); window.navigation.reload(); }); }); }) } 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 添加顶栏置顶链接功能(){ $(function(){ function setLink() { var link = prompt("请输入链接地址(为空清除)"); if (link == undefined) { GM_setValue("user_link", undefined);return; } var text = prompt("请输入链接文字"); GM_setValue("user_link", link); GM_setValue("user_link_text", text); } var title = $(".link-container"); 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.style.marginLeft="50px"; button.addEventListener('click', setLink); var helper = ''; if (pretext != undefined) { title.append(link, helper); } title.append(button, helper); GM_addValueChangeListener( "user_link", function (name, old_value, new_value, remote) { document.querySelector("#userLink").href=new_value; } ); GM_addValueChangeListener( "user_link_text", function (name, old_value, new_value, remote) { document.querySelector("#userLink").innerText=new_value; } ); }); } 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 = $(`

查找用户

`); $finder.insertAfter($firstele); var find_func = function() { $('#find-user-button').addClass('am-disabled'); $.get("/api/user/search?keyword=" + $('[name=finder-uid]')[0].value, function (data) { var arr = data; if (!arr['users'][0]) { $('#find-user-button').removeClass('am-disabled'); show_alert("好像哪里有点问题", "无法找到指定用户"); } else { location.href = "/user/"+arr['users'][0]['uid']; } } ); return false; }; $('#find-user-button').click(find_func); $('#find-user-form').submit(find_func); },500)}); } (function() { 'use strict'; if (location.href.match("://www.luogu.com.cn/user/")){ try{ 移除用户主页维护提示(); }catch(e){console.error(e)} } if (location.href=="https://www.luogu.com.cn/"){ try{ 洛谷大吉每一天(); }catch(e){console.error(e)} try{ 移除首页多余元素(); }catch(e){console.error(e)} try{ 添加用户查找功能(); }catch(e){console.error(e)} } if (location.href.match("://www.luogu.com.cn/")){ try{ 添加顶栏置顶链接功能(); }catch(e){console.error(e)} try{ 添加清理系统生成动态功能(); }catch(e){console.error(e)} } })();