Better Luogu!

Luogu Expansion

当前为 2024-08-08 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Better Luogu!
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.5.2
  5. // @description:zh 洛谷扩展
  6. // @description Luogu Expansion
  7. // @author volatile
  8. // @match *://*.luogu.com.cn/*
  9. // @match *://*.luogu.com/*
  10. // @icon https://fecdn.luogu.com.cn/luogu/logo.png?0fdd294ff62e331d2f70e1a37ba4ee02
  11. // @grant GM_addStyle
  12. // @grant GM_getValue
  13. // @grant GM_setValue
  14. // @grant GM_deleteValue
  15. // @grant GM_listValues
  16. // @grant GM_setClipboard
  17. // @grant GM_xmlhttpRequest
  18. // @grant GM_getResourceText
  19. // @grant unsafeWindow
  20. // @connect baidu.com
  21. // @require https://unpkg.com/sweetalert/dist/sweetalert.min.js
  22. // @license MIT
  23. // ==/UserScript==
  24.  
  25. (function() {
  26. 'use strict';
  27. //进入插件
  28. console.log("This is Better Luogu!");
  29. console.log("\n _____ _____ _____ _____ _____ \n /\\ \\ /\\ \\ /\\ \\ /\\ \\ /\\ \\ \n /::\\____\\ /::\\ \\ /::\\____\\ /::\\____\\ /::\\ \\ \n /::::| | /::::\\ \\ /:::/ / /:::/ / /::::\\ \\ \n /:::::| | /::::::\\ \\ /:::/ _/___ /:::/ / /::::::\\ \\ \n /::::::| | /:::/\\:::\\ \\ /:::/ /\\ \\ /:::/ / /:::/\\:::\\ \\ \n /:::/|::| | /:::/__\\:::\\ \\ /:::/ /::\\____\\ /:::/ / /:::/ \\:::\\ \\ \n /:::/ |::| | /::::\\ \\:::\\ \\ /:::/ /:::/ / /:::/ / /:::/ \\:::\\ \\ \n /:::/ |::| | _____ /::::::\\ \\:::\\ \\ /:::/ /:::/ _/___ /:::/ / /:::/ / \\:::\\ \\ \n /:::/ |::| |/\\ \\ /:::/\\:::\\ \\:::\\ \\ /:::/___/:::/ /\\ \\ /:::/ / /:::/ / \\:::\\ ___\\ \n/:: / |::| /::\\____\\/:::/__\\:::\\ \\:::\\____\\|:::| /:::/ /::\\____\\/:::/____/ /:::/____/ ___\\:::| |\n\\::/ /|::| /:::/ /\\:::\\ \\:::\\ \\::/ /|:::|__/:::/ /:::/ /\\:::\\ \\ \\:::\\ \\ /\\ /:::|____|\n \\/____/ |::| /:::/ / \\:::\\ \\:::\\ \\/____/ \\:::\\/:::/ /:::/ / \\:::\\ \\ \\:::\\ /::\\ \\::/ / \n |::|/:::/ / \\:::\\ \\:::\\ \\ \\::::::/ /:::/ / \\:::\\ \\ \\:::\\ \\:::\\ \\/____/ \n |::::::/ / \\:::\\ \\:::\\____\\ \\::::/___/:::/ / \\:::\\ \\ \\:::\\ \\:::\\____\\ \n |:::::/ / \\:::\\ \\::/ / \\:::\\__/:::/ / \\:::\\ \\ \\:::\\ /:::/ / \n |::::/ / \\:::\\ \\/____/ \\::::::::/ / \\:::\\ \\ \\:::\\/:::/ / \n /:::/ / \\:::\\ \\ \\::::::/ / \\:::\\ \\ \\::::::/ / \n /:::/ / \\:::\\____\\ \\::::/ / \\:::\\____\\ \\::::/ / \n \\::/ / \\::/ / \\::/____/ \\::/ / \\::/____/ \n \\/____/ \\/____/ ~~ \\/____/ \n ");
  30.  
  31. var css = ".newlgmenu{width: 100vw; height: 80vh; display: none; align-items: center; justify-content: center; font-size: 16px; } .NEWLG-menu{width: 600px; height: 550px; display: flex; flex-direction: column; padding: 40px; position: relative; z-index: 100; background: inherit; border-radius: 18px; overflow: hidden; color: black; } .NEWLG-menu::before{ content: \"\"; width: calc\(100% + 20px\); height: calc\(100% + 20px\); position: absolute; top: -10px; left: -10px; overflow:hidden; background: inherit; box-shadow: inset 0 0 0 200px rgba\(255, 255, 255, 0.75\); filter: blur\(5px\); z-index: -1; } .NEWLG-menu input { margin: 6px 0; height: 36px; border: none; background-color: rgba\(255, 255, 255, 0.75\); border-radius: 4px; padding: 0 14px; color: #3d5245; } .NEWLG-menu button { border: none; background: transparent; } .search-container { width: 10%; height: 50px; display: none; z-index: 114514; position: fixed; top: 20px; left: 500px; }.search-box {padding: 10px;border: 1px solid #ddd;border-radius: 4px;font-size: 16px;transition: border-color 0.3s;}.search-box:focus {border-color: #4A90E2;box-shadow: 0 0 8px rgba(74, 144, 226, 0.5);} #mask { position: fixed; left: 0; top: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.5); z-index: 1000; }";
  32. var style = document.createElement("style");
  33. style.innerHTML = css;
  34. document.head.appendChild(style);
  35.  
  36. let nowurl = window.location.href;
  37. console.log(nowurl);
  38.  
  39. let nowcolor1;
  40. let nowcolor="";
  41. if(nowurl == 'https://www.luogu.com.cn/'){
  42. nowcolor1 = document.querySelector('#app-old > div.lg-index-content.am-center > div:nth-child(1) > div > div > div > div.am-u-md-4.lg-punch.am-text-center > h2 > a').className;
  43. for(let i=0;i<nowcolor1.length;i++){
  44. if(nowcolor1[i]==' ') break;
  45. nowcolor = nowcolor + nowcolor1[i];
  46. }
  47. }
  48. console.log(nowcolor);
  49.  
  50. function setcookie(name,value,days,path,domain,secure){
  51. let expires = "";
  52. if(days){
  53. let date = new Date();
  54. date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
  55. expires = "; expires=" + date.toUTCString();
  56. }
  57. var cookieString = name + "=" + (value || "") + expires;
  58. if(path) cookieString += "; path=" + path;
  59. if(domain) cookieString += "; domain=" + domain;
  60. if(secure && window.location.protocol === "https:") cookieString += "; secure";
  61. document.cookie = cookieString;
  62. }
  63.  
  64. function getcookie(name){
  65. const cookiestring = document.cookie;
  66. const cookies = cookiestring.split('; ');
  67. for(const cookie of cookies){
  68. const [cookiename, cookievalue] = cookie.split('=');
  69. if(cookiename === name) return cookievalue;
  70. }
  71. if(name == 'color'){
  72. setcookie('color',nowcolor,114514,'/','luogu.com.cn',true);
  73. return nowcolor;
  74. }
  75. else if(name == 'hanger'){
  76. setcookie('hanger','null',114514,'/','luogu.com.cn',true);
  77. return "null";
  78. }
  79. else if(name == 'version'){
  80. setcookie('version','1.5.2',114514,'/','luogu.com.cn',true);
  81. return "1.5.2";
  82. }
  83. }
  84.  
  85.  
  86. function deletecookie(name){
  87. document.cookie = name+ '=; expires=Thu, 01 Jan 1970 00:00:01 GMT; path=/';
  88. }
  89.  
  90. function colorschange(changecolor){//emm,这个函数,额,可能要用吧
  91. if(changecolor == 'lg-fg-gray') return 'rgb\(191, 191, 191\)';
  92. else if(changecolor == 'lg-fg-blue') return 'rgb\(14, 144, 210\)';
  93. else if(changecolor == 'lg-fg-green') return 'rgb\(94, 185, 94\)';
  94. else if(changecolor == 'lg-fg-orange') return 'rgb\(230, 126 34\)';
  95. else if(changecolor == 'lg-fg-red') return 'rgb\(231, 76, 60\)';
  96. else if(changecolor == 'lg-fg-purple') return 'rgb\(142, 68, 173\)';
  97. else if(changecolor == 'lg-fg-brown') return 'rgb\(173, 139, 0\)';
  98. }
  99.  
  100. if(getcookie('version') != '1.5.2'){
  101. setcookie('version','1.5.2',114514,'/','luogu.com.cn',true);
  102. swal("Better Luogu! 1.5.2","更新:修复了关于cookie的bug(除非这已经是你第二次见到这个提示了)");
  103. }
  104.  
  105. let changecolor = getcookie('color');
  106.  
  107. let tagchange = getcookie('tag');
  108. let tag = document.createElement("span");
  109. let tagcolor;
  110. if(changecolor != 'lg-fg-blue' && changecolor != 'lg-fg-orange'){
  111. tagcolor = changecolor.replace('fg','bg');
  112. tag.className = 'am-badge am-radius ' + tagcolor;
  113. }
  114. else if(changecolor == 'lg-fg-blue'){
  115. tagcolor = 'color-none';
  116. tag.className = 'am-badge am-radius ' + tagcolor;
  117. tag.style.background = 'rgb(52, 152, 219)';
  118. }
  119. else if(changecolor == 'lg-fg-orange'){
  120. tagcolor = 'color-none';
  121. tag.className = 'am-badge am-radius ' + tagcolor;
  122. tag.style.background = 'rgb(243, 156, 17)';
  123. }
  124. if(changecolor != 'lg-fg-brown') tag.textContent = tagchange;
  125. else tag.textContent = '作弊者';
  126.  
  127. //首页
  128. if(nowurl == 'https://www.luogu.com.cn/'){
  129. //日历
  130. const today=new Date();
  131. const year=today.getFullYear();
  132. const month=String(today.getMonth()+1);
  133. const day=String(today.getDate());
  134. console.log(year);
  135. console.log(month);
  136. console.log(day);
  137. let date_html='<h2>今天是 '+year+'-'+month+'-'+day+'</h2>';
  138. if(month==1&&day==1){
  139. date_html+='<h2>今天是元旦,新的一年,新的开始</h2>';
  140. }
  141. else if(month==2&&day==29){
  142. date_html+='<h2>今年是闰年</h2>';
  143. }
  144. else if(month==4&&day==1){
  145. date_html+='<h2>今天是愚人节</h2>';
  146. }
  147. else if(month==5&&day==1){
  148. date_html+='<h2>今天是劳动节</h2>';
  149. }
  150. else if(month==6&&day==1){
  151. date_html+='<h2>今天是儿童节</h2>';
  152. }
  153. else if(month==9&&day==10){
  154. date_html+='<h2>今天是教师节</h2>';
  155. }
  156. else if(month==10&&day==1){
  157. date_html+='<h2>今天是国庆节,七天小长假,启动!</h2>'
  158. }
  159. else if(month==12&&day==31){
  160. date_html+='<h2>明年见</h2>';
  161. }
  162. else{
  163. date_html+='<h2>欢迎!</h2>';
  164. }
  165. let date = document.createElement('div');
  166. date.className = 'lg-article';
  167. date.innerHTML = date_html;
  168. document.querySelector('div.lg-right > div:nth-child(1)').insertAdjacentElement('beforebegin', date);
  169.  
  170. //更改用户名颜色
  171. let color = document.querySelector('#app-old > div.lg-index-content.am-center > div:nth-child(1) > div > div > div > div.am-u-md-4.lg-punch.am-text-center > h2 > a');
  172. console.log(color);
  173. if(changecolor != 'null') color.className=changecolor;
  174.  
  175. function removeDivWithText(text) {
  176. document.querySelectorAll('div').forEach(div => {
  177. if(div.textContent === text) div.remove();
  178. });
  179. }
  180.  
  181. function findElement(element, text, cclass){
  182. document.querySelectorAll(element).forEach(E => {
  183. if(E.textContent === text) E.className = cclass;
  184. });
  185. }
  186.  
  187. removeDivWithText('暂无推荐');
  188. removeDivWithText('洛谷根据您近期的做题情况,使用机器学习自动为您推荐符合您目前程度的题目。本列表每日更新一次。');
  189.  
  190. GM_xmlhttpRequest({
  191. method: "GET",
  192. url: 'https://top.baidu.com/board?tab=realtime',
  193. onload: function(response){
  194. let rs = new DOMParser();
  195. let doc = rs.parseFromString(response.responseText, "text/html");
  196. for(let i=1;i<=5;i++){
  197. let th = i.toString();
  198. let selector = '#sanRoot > main > div.container.right-container_2EFJr > div > div:nth-child(2) > div:nth-child(' + th + ') > div.content_1YWBm > a > div.c-single-text-ellipsis';
  199. let _rs = doc.querySelector(selector);
  200. console.log(_rs.textContent);
  201. let selector2 = '#sanRoot > main > div.container.right-container_2EFJr > div > div:nth-child(2) > div:nth-child(' + th + ') > div.content_1YWBm > a';
  202. let rslink = doc.querySelector(selector2);
  203. console.log(rslink);
  204. let link = document.createElement("a");
  205. link.href = rslink.href;
  206. link.textContent = _rs.textContent;
  207. let RS = document.createElement("p");
  208. RS.appendChild(link);
  209. findElement('h2','智能推荐','zntj');
  210. document.getElementsByClassName('zntj')[0].parentNode.append(RS);
  211. }
  212. }
  213. });
  214. }
  215.  
  216. window.onload = function(){
  217. let _hanger = getcookie('hanger');
  218. let __hanger = document.createElementNS('http://www.w3.org/2000/svg','svg');
  219. __hanger.setAttribute('width','16');
  220. __hanger.setAttribute('height','16');
  221. __hanger.setAttribute('viewBox','0 0 16 16');
  222. __hanger.setAttribute('style','margin-bottom: -3px;');
  223.  
  224. if(_hanger == 'green') __hanger.setAttribute('fill','#5eb95e');
  225. else if(_hanger == 'blue') __hanger.setAttribute('fill','#3498db');
  226. else if(_hanger == 'golden') __hanger.setAttribute('fill','#f1c40f');
  227.  
  228. let ___hanger = document.createElementNS('http://www.w3.org/2000/svg','path');
  229. ___hanger.setAttribute('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');
  230. __hanger.appendChild(___hanger);
  231. let _hanger_ = document.createElement("a");
  232. _hanger_.href = 'https://www.luogu.com/discuss/142324';
  233. _hanger_.appendChild(__hanger);
  234.  
  235. let button = document.createElement("a");
  236. button.innerHTML = '<button id="NLTB" style=\"background-color: rgb\(94,114,228\);border-radius: 7px;color: white;border: none;padding: 7px 12px;text-align: center;text-decoration: none;display: inline-block;font-size: 16px;margin: 4px 2px;cursor: pointer;border: none;box-shadow: 2px 3px 7px #000;\">NEWLG</button>';
  237. let menu = document.createElement("div");
  238. menu.innerHTML = '<div class=\"newlgmenu\"><from class=\"NEWLG-menu\"><h2>v1.5</h2><h3>用户名颜色</h3><input type="text" placeholder="更改名字颜色为(如“紫名”“复原”“recover”“red”)" id="nlcolor"><button id="submitcolor">提交</button><h3>勾子<h3><button id="greenhanger"><svg xmlns="http://www.w3.org/2000/svg" width="50" height="50" viewBox="0 0 16 16" fill="#5eb95e" 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></button><button id="bluehanger"><svg xmlns="http://www.w3.org/2000/svg" width="50" height="50" viewBox="0 0 16 16" fill="#3498db" 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></button><button id="goldenhanger"><svg xmlns="http://www.w3.org/2000/svg" width="50" height="50" 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></button><button id="nullhanger"><svg xmlns="http://www.w3.org/2000/svg" width="50" height="50" viewBox="0 0 50 50" overflow="visible" stroke="red" stroke-width="10" stroke-linecap="round"><line x2="50" y2="50" fill="red"/><line x1="50" y2="50" fill="red"/></svg></button><h2>Tag</h2><input type="text" id="nltag" placeholder="无输入以取消,长度不超过10"><button id="submittag">提交</button></from></div>';
  239. if(nowurl == 'https://www.luogu.com.cn/' || nowurl == 'https://www.luogu.com.cn/chat' || nowurl.includes('https://www.luogu.com.cn/user/notification') || (nowurl.includes('https://www.luogu.com.cn/user/') && !nowurl.includes('https://www.luogu.com.cn/user/setting'))){
  240. document.querySelector('#app > div.main-container > div.wrapper.wrapped.lfe-body.header-layout.tiny > div.container > nav').insertAdjacentElement('beforebegin', button);
  241. document.querySelector("#app > div.main-container > div.wrapper.wrapped.lfe-body.header-layout.tiny > div.container").parentNode.append(menu);
  242. }
  243. else{
  244. let user_nav = document.querySelector('div.user-nav[data-v-2dfcfd35]');
  245. let c_usernav = document.querySelector('nav[data-v-2dfcfd35]');
  246. user_nav.style.verticalAlign = 'middle';
  247. c_usernav.insertBefore(button,c_usernav.firstChild);
  248. button.href = 'https://zhuangjihong.github.io/NEWLG/';
  249. }
  250. const tb = document.getElementById("NLTB");
  251. let menudisplay = document.getElementsByClassName("newlgmenu")[0];
  252.  
  253. function reloadmenu(){
  254. swal("Better Luogu!","更改成功","success",{button: "刷新"}).then((value) => {location.reload();});
  255. }
  256.  
  257. tb.addEventListener('click', function(){
  258. if(menudisplay.style.display == 'none'){
  259. menudisplay.style.display = 'flex';
  260. document.body.style.overflow = 'hidden';
  261. tb.textContent = "EXIT";
  262. }
  263. else{
  264. menudisplay.style.display = 'none';
  265. document.body.style.overflow = 'visible';
  266. tb.textContent = "NEWLG";
  267. }
  268.  
  269. const submitcolor = document.getElementById('submitcolor');
  270. const greenhanger = document.getElementById('greenhanger');
  271. const bluehanger = document.getElementById('bluehanger');
  272. const goldenhanger = document.getElementById('goldenhanger');
  273. const nullhanger = document.getElementById('nullhanger');
  274.  
  275. submitcolor.addEventListener('click', function(){
  276. let colorchange = document.getElementById('nlcolor').value;
  277. console.log(colorchange);
  278. deletecookie('color');
  279. if(colorchange=='灰名'||colorchange=='gray'){
  280. deletecookie('color');
  281. setcookie('color','lg-fg-gray',114514,'/','luogu.com.cn',true);
  282. reloadmenu();
  283. }
  284. else if(colorchange=='蓝名'||colorchange=='blue'){
  285. deletecookie('color');
  286. setcookie('color','lg-fg-blue',114514,'/','luogu.com.cn',true);
  287. reloadmenu();
  288. }
  289. else if(colorchange=='绿名'||colorchange=='green'){
  290. deletecookie('color');
  291. setcookie('color','lg-fg-green',114514,'/','luogu.com.cn',true);
  292. reloadmenu();
  293. }
  294. else if(colorchange=='橙名'||colorchange=='orange'){
  295. deletecookie('color');
  296. setcookie('color','lg-fg-orange',114514,'/','luogu.com.cn',true);
  297. reloadmenu();
  298. }
  299. else if(colorchange=='红名'||colorchange=='red'){
  300. deletecookie('color');
  301. setcookie('color','lg-fg-red',114514,'/','luogu.com.cn',true);
  302. reloadmenu();
  303. }
  304. else if(colorchange=='紫名'||colorchange=='purple'){
  305. deletecookie('color');
  306. setcookie('color','lg-fg-purple',114514,'/','luogu.com.cn',true);
  307. reloadmenu();
  308. }
  309. else if(colorchange=='棕名'||colorchange=='brown'){
  310. deletecookie('color');
  311. setcookie('color','lg-fg-brown',114514,'/','luogu.com.cn',true);
  312. reloadmenu();
  313. }
  314. else if(colorchange=='复原'||colorchange=='recover'){
  315. deletecookie('color');
  316. setcookie('color',nowcolor,114514,'/','luogu.com.cn',true);
  317. reloadmenu();
  318. }
  319. else swal("Better Luogu!","请按规范输入","error");
  320. });
  321. greenhanger.addEventListener('click', function(){
  322. deletecookie('hanger');
  323. setcookie('hanger','green',114514,'/','luogu.com.cn',true);
  324. reloadmenu();
  325. });
  326. bluehanger.addEventListener('click', function(){
  327. deletecookie('hanger');
  328. setcookie('hanger','blue',114514,'/','luogu.com.cn',true);
  329. reloadmenu();
  330. });
  331. goldenhanger.addEventListener('click', function(){
  332. deletecookie('hanger');
  333. setcookie('hanger','golden',114514,'/','luogu.com.cn',true);
  334. reloadmenu();
  335. });
  336. nullhanger.addEventListener('click',function(){
  337. deletecookie('hanger');
  338. setcookie('hanger','null',114514,'/','luogu.com.cn',true);
  339. reloadmenu();
  340. });
  341.  
  342. const submittag = document.getElementById('submittag');
  343. submittag.addEventListener('click', function(){
  344. let tagchange = document.getElementById('nltag').value;
  345. if(getcookie('color') == 'lg-fg-brown') swal("Better Luogu!","当前为棕名","error");
  346. else if(tagchange.length > 10) swal("Better Luogu!","长度应不大于10","error");
  347. else{
  348. deletecookie('tag');
  349. setcookie('tag',tagchange,114514,'/','luogu.com.cn',true);
  350. reloadmenu();
  351. }
  352. });
  353. });
  354. if(nowurl == 'https://www.luogu.com.cn/'){
  355. if(getcookie('hanger')!='null'){
  356. document.querySelector('#app-old > div.lg-index-content.am-center > div:nth-child(1) > div > div > div > div.am-u-md-4.lg-punch.am-text-center > h2 > a').innerHTML += '&nbsp;';
  357. document.querySelector('#app-old > div.lg-index-content.am-center > div:nth-child(1) > div > div > div > div.am-u-md-4.lg-punch.am-text-center > h2 > a').appendChild(_hanger_);
  358. }
  359. if(getcookie('tag')!='null'){
  360. document.querySelector('#app-old > div.lg-index-content.am-center > div:nth-child(1) > div > div > div > div.am-u-md-4.lg-punch.am-text-center > h2 > a').innerHTML += '&nbsp;';
  361. document.querySelector('#app-old > div.lg-index-content.am-center > div:nth-child(1) > div > div > div > div.am-u-md-4.lg-punch.am-text-center > h2 > a').appendChild(tag);
  362. }
  363. }
  364. else if(nowurl.includes('https://www.luogu.com.cn/user/')&&!nowurl.includes('https://www.luogu.com.cn/user/setting')){
  365. if(document.querySelector('#app > div.main-container > main > div > div.full-container > section.main > div > div:nth-child(2)').className == 'introduction marked') document.querySelector('#app > div.main-container > main > div > div.full-container > section.main > div > div:nth-child(2)').removeAttribute('style');
  366. else document.querySelector('#app > div.main-container > main > div > div.full-container > section.main > div > div:nth-child(2)').remove();
  367. let jieshao = document.querySelector('#app > div.main-container > main > div > div.full-container > section.main > div > div.introduction.marked');
  368. if(jieshao.style.display == 'none') jieshao.removeAttribute('style');
  369. }
  370. };
  371. })();