luogu_better

更好的洛谷!

  1. // ==UserScript==
  2. // @name luogu_better
  3. // @namespace https://www.luogu.com.cn
  4. // @version 0.1.2
  5. // @license MIT
  6. // @description 更好的洛谷!
  7. // @author rabbit
  8. // @match https://www.luogu.com.cn/*
  9. // @icon https://www.luogu.com.cn/favicon.ico
  10. // ==/UserScript==
  11.  
  12. window.addEventListener('load', function() {
  13. console.log("luogu_beautification loaded | Made by Rabbit");
  14. // 函数:应用样式
  15. function applyStyles() {
  16. const style = document.createElement("style");
  17. style.innerHTML = `
  18. body {
  19. background-image: url('https://bing.img.run/uhd.php') !important;
  20. background-size: cover;
  21. }
  22. .lg-article {
  23. border-radius: 9px !important;
  24. }
  25. .lg-article .lg-index-stat {
  26. border-radius: 9px !important;
  27. }
  28. .card.padding-default {
  29. border-radius: 9px !important;
  30. }
  31. .card.wrapper.padding-none {
  32. border-radius: 9px !important;
  33. }
  34. .lfe-form-sz-middle {
  35. border-radius: 9px !important;
  36. }
  37. .refined-input.input-wrap.frame {
  38. border-radius: 18px !important;
  39. padding: 5px;
  40. }
  41. input {
  42. border-radius: 18px !important;
  43. padding: 5px;
  44. }
  45. .center {
  46. border-radius: 9px !important;
  47. }
  48. .card.user-header-container.padding-0 {
  49. border-radius: 9px !important;
  50. }
  51. .card {
  52. border-radius: 9px !important;
  53. }
  54. .l-card {
  55. border-radius: 9px !important;
  56. }
  57. .columba-content-wrap {
  58. border-radius: 9px !important;
  59. }
  60. .text {
  61. border-radius: 18px !important;
  62. padding: 5px;
  63. }
  64. .casket {
  65. border-radius: 9px !important;
  66. }
  67. .dropdown {
  68. border-radius: 9px !important;
  69. }
  70. .am-comments-list {
  71. background-color:rgb(250,250,250);
  72. border-radius: 9px !important;
  73. overflow: auto;
  74. }
  75. textarea {
  76. border-radius: 9px !important;
  77. }
  78. `;
  79.  
  80. document.head.appendChild(style);
  81. }
  82.  
  83. // 首次加载时应用样式
  84. applyStyles();
  85.  
  86. // 创建 MutationObserver 以监控 DOM 变化
  87. const observer = new MutationObserver(function(mutations) {
  88. mutations.forEach(function(mutation) {
  89. if (mutation.addedNodes.length > 0) {
  90. applyStyles(); // 当有新元素被添加时重新应用样式
  91. }
  92. });
  93. });
  94.  
  95. // 开始监听 document.body 的子元素变化(包括整个 DOM 树的变化)
  96. observer.observe(document.body, { childList: true, subtree: true });
  97. });
  98. window.back = "https://bing.img.run/uhd.php";
  99. setInterval(function(){
  100. document.querySelector('body').style=`background: url(${window.back}) fixed center;background-size: cover;`;
  101. if(document.querySelector('main[style="background-color: rgb(239, 239, 239);"]') != null)
  102. document.querySelector('main[style="background-color: rgb(239, 239, 239);"]').style="opacity: 0.9;";
  103. if(document.querySelector('div[style="background: linear-gradient(90deg, rgb(35, 37, 38), rgb(65, 67, 69)); filter: blur(0px) brightness(100%);"]') != null)
  104. document.querySelector('div[style="background: linear-gradient(90deg, rgb(35, 37, 38), rgb(65, 67, 69)); filter: blur(0px) brightness(100%);"]').style="opacity: 0.9;";
  105. if(document.querySelector('div[style="background: rgb(51, 51, 51); filter: blur(0px) brightness(100%);"]') != null)
  106. document.querySelector('div[style="background: rgb(51, 51, 51); filter: blur(0px) brightness(100%);"]').style="opacity: 0.9;";
  107. if(document.querySelector('div[class="mdui-panel mdui-panel-gapless"]') != null)
  108. document.querySelector('div[class="mdui-panel mdui-panel-gapless"]').style="opacity: 0.9;";
  109. if(document.querySelector("div[data-v-0a593618]") != null){
  110. document.querySelector("div[data-v-0a593618]").remove();
  111. }
  112. },100);
  113. (function(){
  114. const $=document.getElementsByClassName.bind(document);
  115.  
  116. window.onload=function(){
  117. var myVar = setInterval(function(){
  118. //alert("Hello");
  119. const findElem=findElemByText.bind($("lfe-form-sz-small"))
  120. const sub=findElem("关闭");
  121. if(sub){
  122. sub.click();
  123. clearInterval(myVar);
  124. }
  125. }, 100);
  126. }
  127.  
  128. function findElemByText(text) {
  129. for (const elem of this) {
  130. if (elem.innerText.includes(text)) {
  131. return elem
  132. }
  133. }
  134. return null
  135. }
  136. })();
  137. (function() {
  138. 'use strict';
  139. 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();
  140. 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();
  141. document.querySelector("#app-old > div.lg-index-content.am-center > div:nth-child(1) > div > div > div > div.am-u-md-8").remove();
  142. 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();
  143. 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";
  144. 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();
  145. 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();
  146. 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();
  147. 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();
  148. 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();
  149. 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();
  150. 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();
  151. })();
  152. $('document').ready(function(){
  153. var x=document.querySelectorAll(".lg-punch-result");
  154. var y=document.querySelectorAll(".am-u-sm-6");
  155. if(x[0].innerHTML=="§ 大凶 §"){
  156. var sum="<span id='yi' style='font-weight:bold'>宜:</span>学习<br><span style='font-size:10px;color:#7f7f7f'>学业有成</span></br>";
  157. sum+="<span id='yi' style='font-weight:bold'>宜:</span>继续完成WA的题<br><span style='font-size:10px;color:#7f7f7f'>下一次就可以AC了</span></br>";
  158. y[0].innerHTML=sum;
  159. }
  160. x[0].innerHTML="§ 大吉 §";
  161. x[0].style="color:#e74c3c!important";
  162. y[1].innerHTML="万事皆宜";
  163. y[1].style="color:rgba(0, 0, 0, .75)!important";
  164. y[1].style="font-weight:bold";
  165. });
  166. //随机跳题 参考自叶ID的作品
  167. setTimeout(function () {
  168. document.querySelector('div[class="am-u-md-3"]').innerHTML = `
  169. <div class="lg-article" id="rand-problem-form">
  170. <h2>随机跳题 v1.0</h2>
  171. <select class="am-form-field" style="background-color:#DDD;" name="rand-problem-rating" autocomplete="off" placeholder="选择难度">
  172. <option value="0">暂无评定</option>
  173. <option value="1">入门</option>
  174. <option value="2">普及-</option>
  175. <option value="3">普及/提高-</option>
  176. <option value="4">普及+/提高</option>
  177. <option selected value="5">提高+/省选-</option>
  178. <option value="6">省选/NOI-</option>
  179. <option value="7">NOI/NOI+/CTSC</option>
  180. </select>
  181. <select class="am-form-field" style="background-color:#DDD;margin-top:16px;" name="rand-problem-source" autocomplete="off" placeholder="选择来源">
  182. <option selected value="P">洛谷题库</option>
  183. <option value="CF">CodeForces</option>
  184. <option value="SP">SPOJ</option>
  185. <option value="AT">AtCoder</option>
  186. <option value="UVA">UVa</option>
  187. </select>
  188. <button class="am-btn am-btn-sm am-btn-primary" style="margin-top:16px;visibility:hidden">跳转</button>
  189. <button class="am-btn am-btn-sm am-btn-primary lg-right" id="rand-problem-button" style="margin-top:16px;">跳转</button>
  190. </div>`;
  191. $('#rand-problem-button').click(function() {
  192. $('#rand-problem-button').addClass('am-disabled');
  193. $.get("https://www.luogu.com.cn/problem/list?difficulty=" + $('[name=rand-problem-rating]')[0].value + "&type=" + $('[name=rand-problem-source]')[0].value + "&page=1&_contentOnly=1",
  194. function (data) {
  195. var arr = data;
  196. if (arr['code'] != 200) {
  197. $('#rand-problem-button').removeClass('am-disabled');
  198. show_alert("出现了一些问题~", arr["message"]);
  199. }
  200. else {
  201. var problem_count = arr['currentData']['problems']['count'];
  202. var page_count = Math.ceil(problem_count / 50);
  203. var rand_page = Math.floor(Math.random()*page_count) + 1;
  204. $.get("https://www.luogu.com.cn/problem/list?difficulty=" + $('[name=rand-problem-rating]')[0].value + "&type=" + $('[name=rand-problem-source]')[0].value + "&page=" + rand_page + "&_contentOnly=1",
  205. function(data) {
  206. var list = data['currentData']['problems']['result'];
  207. var rand_idx = Math.floor(Math.random()*list.length);
  208. var pid = list[rand_idx]['pid'];
  209. location.href = "https://www.luogu.com.cn/problem/" + pid;
  210. }
  211. );
  212. }
  213. }
  214. );
  215. });
  216. },499);
  217. $('document').ready(function () {
  218. 'use strict';
  219. if (window._feInjection.currentUser == null) return;
  220. const color = window._feInjection.currentUser.color;
  221. const uid = window._feInjection.currentUser.uid.toString();
  222. const username = window._feInjection.currentUser.name;
  223. console.log(color);
  224. console.log(uid);
  225. console.log(username);
  226. var classname = "lg-fg-"+color.toLowerCase();
  227. if (color.toLowerCase() == "red" || color.toLowerCase() == "orange") classname += " lg-bold";
  228. if (color.toLowerCase() == "blue") classname += "light";
  229. var tar = document.getElementsByClassName(classname);
  230. var ele = "&nbsp;<a class=\"sb_amazeui\" target=\"_blank\" href=\"/discuss/show/142324\"><svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"#f1c40f\" style=\"margin-bottom: -3px;\"><path d=\"M16 8C16 6.84375 15.25 5.84375 14.1875 5.4375C14.6562 4.4375 14.4688 3.1875 13.6562 2.34375C12.8125 1.53125 11.5625 1.34375 10.5625 1.8125C10.1562 0.75 9.15625 0 8 0C6.8125 0 5.8125 0.75 5.40625 1.8125C4.40625 1.34375 3.15625 1.53125 2.34375 2.34375C1.5 3.1875 1.3125 4.4375 1.78125 5.4375C0.71875 5.84375 0 6.84375 0 8C0 9.1875 0.71875 10.1875 1.78125 10.5938C1.3125 11.5938 1.5 12.8438 2.34375 13.6562C3.15625 14.5 4.40625 14.6875 5.40625 14.2188C5.8125 15.2812 6.8125 16 8 16C9.15625 16 10.1562 15.2812 10.5625 14.2188C11.5938 14.6875 12.8125 14.5 13.6562 13.6562C14.4688 12.8438 14.6562 11.5938 14.1875 10.5938C15.25 10.1875 16 9.1875 16 8ZM11.4688 6.625L7.375 10.6875C7.21875 10.8438 7 10.8125 6.875 10.6875L4.5 8.3125C4.375 8.1875 4.375 7.96875 4.5 7.8125L5.3125 7C5.46875 6.875 5.6875 6.875 5.8125 7.03125L7.125 8.34375L10.1562 5.34375C10.3125 5.1875 10.5312 5.1875 10.6562 5.34375L11.4688 6.15625C11.5938 6.28125 11.5938 6.5 11.4688 6.625Z\"></path></svg></a>";
  231. for (var i = 0; i < tar.length; i++)
  232. {
  233. if (tar[i].attributes['href'].value == "/user/"+uid)
  234. {
  235. tar[i].innerHTML = username+"&nbsp;<a class=\"sb_amazeui\" target=\"_blank\" href=\"/discuss/show/142324\"><svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"#f1c40f\" style=\"margin-bottom: -3px;\"><path d=\"M16 8C16 6.84375 15.25 5.84375 14.1875 5.4375C14.6562 4.4375 14.4688 3.1875 13.6562 2.34375C12.8125 1.53125 11.5625 1.34375 10.5625 1.8125C10.1562 0.75 9.15625 0 8 0C6.8125 0 5.8125 0.75 5.40625 1.8125C4.40625 1.34375 3.15625 1.53125 2.34375 2.34375C1.5 3.1875 1.3125 4.4375 1.78125 5.4375C0.71875 5.84375 0 6.84375 0 8C0 9.1875 0.71875 10.1875 1.78125 10.5938C1.3125 11.5938 1.5 12.8438 2.34375 13.6562C3.15625 14.5 4.40625 14.6875 5.40625 14.2188C5.8125 15.2812 6.8125 16 8 16C9.15625 16 10.1562 15.2812 10.5625 14.2188C11.5938 14.6875 12.8125 14.5 13.6562 13.6562C14.4688 12.8438 14.6562 11.5938 14.1875 10.5938C15.25 10.1875 16 9.1875 16 8ZM11.4688 6.625L7.375 10.6875C7.21875 10.8438 7 10.8125 6.875 10.6875L4.5 8.3125C4.375 8.1875 4.375 7.96875 4.5 7.8125L5.3125 7C5.46875 6.875 5.6875 6.875 5.8125 7.03125L7.125 8.34375L10.1562 5.34375C10.3125 5.1875 10.5312 5.1875 10.6562 5.34375L11.4688 6.15625C11.5938 6.28125 11.5938 6.5 11.4688 6.625Z\"></path></svg>";
  236. if(tar[i].nextElementSibling != null) {
  237. tar[i].nextElementSibling.innerHTML="";
  238. }
  239. //$(tar[i]).after(ele);
  240. }
  241. }
  242. var css = "";
  243. if (false || (new RegExp("^((?!blog).)*https://www.luogu.com.cn((?!blog).)*$")).test(document.location.href) || (new RegExp("^((?!blog).)*http://www.luogu.com.cn((?!blog).)*$")).test(document.location.href) || (new RegExp("^((?!blog).)*https://www2.luogu.com.cn((?!blog).)*$")).test(document.location.href) || (new RegExp("^((?!blog).)*http://www2.luogu.com.cn((?!blog).)*$")).test(document.location.href)){
  244. css += [
  245. "a[class^=\"lg-fg-\"][href*=\""+uid+"\"] {",
  246. " color: #8e44ad !important;",
  247. "}",
  248. "a[class^=\"lg-fg-\"][href*=\""+uid+"\"]:after {",
  249. " content:\"管理员\";",
  250. " display: inline-block;",
  251. " min-width: 10px;",
  252. " padding: .25em .625em;",
  253. " font-size: 1.2rem;",
  254. " font-weight: 700;",
  255. " color: #fff;",
  256. " line-height: 1;",
  257. " vertical-align: baseline;",
  258. " white-space: nowrap;",
  259. " background-color: #8e44ad;",
  260. " border-radius: 50px;",
  261. " margin-left: 3px;",
  262. " padding-left: 10px;",
  263. " padding-right: 10px;",
  264. " padding-top: 4px;",
  265. " padding-bottom: 4px;",
  266. " transition: all .15s;",
  267. "}"
  268. ].join("\n");
  269. // 如果你没有使用氩洛谷
  270.  
  271. /* css += [
  272. "a[class^=\"lg-fg-\"][href*=\""+uid+"\"] {",
  273. " color: #8e44ad !important;",
  274. "}",
  275. "a[class^=\"lg-fg-\"][href*=\""+uid+"\"]:after {",
  276. " content:\"管理员\";",
  277. " display: inline-block;",
  278. " min-width: 10px;",
  279. " padding: .25em .625em;",
  280. " font-size: 1.2rem;",
  281. " font-weight: 700;",
  282. " color: #fff;",
  283. " line-height: 1;",
  284. " vertical-align: baseline;",
  285. " white-space: nowrap;",
  286. " background-color: #8e44ad;",
  287. " margin-left: 3px;",
  288. " transition: all .15s;",
  289. "}"
  290. ].join("\n"); */
  291. if (typeof GM_addStyle != "undefined") {
  292. GM_addStyle(css);
  293. } else if (typeof PRO_addStyle != "undefined") {
  294. PRO_addStyle(css);
  295. } else if (typeof addStyle != "undefined") {
  296. addStyle(css);
  297. } else {
  298. var node = document.createElement("style");
  299. node.type = "text/css";
  300. node.appendChild(document.createTextNode(css));
  301. var heads = document.getElementsByTagName("head");
  302. if (heads.length > 0) {
  303. heads[0].appendChild(node);
  304. } else {
  305. // no head yet, stick it whereever
  306. document.documentElement.appendChild(node);
  307. }
  308. }
  309. }});

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址