new luogu

Luogu Expansion

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

  1. // ==UserScript==
  2. // @name new luogu
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.4.3
  5. // @description Luogu Expansion
  6. // @description:zh 洛谷扩展
  7. // @author volatile
  8. // @match *://*.luogu.org/*
  9. // @match *://*.luogu.com.cn/*
  10. // @icon https://www.google.com/s2/favicons?sz=64&domain=luogu.com.cn
  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. // @license MIT
  22. // ==/UserScript==
  23.  
  24. (function() {
  25. 'use strict';
  26. //进入插件
  27. console.log("This is new luogu");
  28. console.log("\n _____ _____ _____ _____ _____ \n /\\ \\ /\\ \\ /\\ \\ /\\ \\ /\\ \\ \n /::\\____\\ /::\\ \\ /::\\____\\ /::\\____\\ /::\\ \\ \n /::::| | /::::\\ \\ /:::/ / /:::/ / /::::\\ \\ \n /:::::| | /::::::\\ \\ /:::/ _/___ /:::/ / /::::::\\ \\ \n /::::::| | /:::/\\:::\\ \\ /:::/ /\\ \\ /:::/ / /:::/\\:::\\ \\ \n /:::/|::| | /:::/__\\:::\\ \\ /:::/ /::\\____\\ /:::/ / /:::/ \\:::\\ \\ \n /:::/ |::| | /::::\\ \\:::\\ \\ /:::/ /:::/ / /:::/ / /:::/ \\:::\\ \\ \n /:::/ |::| | _____ /::::::\\ \\:::\\ \\ /:::/ /:::/ _/___ /:::/ / /:::/ / \\:::\\ \\ \n /:::/ |::| |/\\ \\ /:::/\\:::\\ \\:::\\ \\ /:::/___/:::/ /\\ \\ /:::/ / /:::/ / \\:::\\ ___\\ \n/:: / |::| /::\\____\\/:::/__\\:::\\ \\:::\\____\\|:::| /:::/ /::\\____\\/:::/____/ /:::/____/ ___\\:::| |\n\\::/ /|::| /:::/ /\\:::\\ \\:::\\ \\::/ /|:::|__/:::/ /:::/ /\\:::\\ \\ \\:::\\ \\ /\\ /:::|____|\n \\/____/ |::| /:::/ / \\:::\\ \\:::\\ \\/____/ \\:::\\/:::/ /:::/ / \\:::\\ \\ \\:::\\ /::\\ \\::/ / \n |::|/:::/ / \\:::\\ \\:::\\ \\ \\::::::/ /:::/ / \\:::\\ \\ \\:::\\ \\:::\\ \\/____/ \n |::::::/ / \\:::\\ \\:::\\____\\ \\::::/___/:::/ / \\:::\\ \\ \\:::\\ \\:::\\____\\ \n |:::::/ / \\:::\\ \\::/ / \\:::\\__/:::/ / \\:::\\ \\ \\:::\\ /:::/ / \n |::::/ / \\:::\\ \\/____/ \\::::::::/ / \\:::\\ \\ \\:::\\/:::/ / \n /:::/ / \\:::\\ \\ \\::::::/ / \\:::\\ \\ \\::::::/ / \n /:::/ / \\:::\\____\\ \\::::/ / \\:::\\____\\ \\::::/ / \n \\::/ / \\::/ / \\::/____/ \\::/ / \\::/____/ \n \\/____/ \\/____/ ~~ \\/____/ \n ");
  29.  
  30. 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; }";
  31. var style = document.createElement("style");
  32. style.innerHTML = css;
  33. document.head.appendChild(style);
  34.  
  35. let nowurl = window.location.href;
  36. console.log(nowurl);
  37.  
  38. let nowcolor1;
  39. let nowcolor="";
  40. if(nowurl == 'https://www.luogu.com.cn/'){
  41. 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;
  42. for(let i=0;i<nowcolor1.length;i++){
  43. if(nowcolor1[i]==' ') break;
  44. nowcolor = nowcolor + nowcolor1[i];
  45. }
  46. }
  47. console.log(nowcolor);
  48.  
  49.  
  50. function getcookie(name){
  51. const cookiestring = document.cookie;
  52. const cookies = cookiestring.split('; ');
  53. for(const cookie of cookies){
  54. const [cookiename, cookievalue] = cookie.split('=');
  55. if(cookiename === name) return cookievalue;
  56. }
  57. if(name == 'color'){
  58. const time = new Date();
  59. time.setDate(time.getDate() + 365);
  60. document.cookie = "color=" + nowcolor + ";expires=" + time.toUTCString();
  61. return nowcolor;
  62. }
  63. else if(name == 'hanger'){
  64. const time = new Date();
  65. time.setDate(time.getDate() + 365);
  66. document.cookie = "hanger=null" + ";expires=" + time.toUTCString();
  67. return "null";
  68. }
  69. else if(name == 'tag'){
  70. const time = new Date();
  71. time.setDate(time.getDate() + 365);
  72. document.cookie = "tag=null" + ";expires=" + time.toUTCString();
  73. return "null";
  74. }
  75. else if(name == 'version'){
  76. const time = new Date();
  77. time.setDate(time.getDate() + 119810);
  78. document.cookie = "version=1.3.1" + ";expires=" + time.toUTCString();
  79. return "1.3.1";
  80. }
  81. }
  82.  
  83. function deletecookie(name){
  84. document.cookie = name+ '=; expires=Thu, 01 Jan 1970 00:00:01 GMT; path=/';
  85. }
  86.  
  87. function colorschange(changecolor){
  88. if(changecolor == 'lg-fg-gray') return 'rgb\(191, 191, 191\)';
  89. else if(changecolor == 'lg-fg-blue') return 'rgb\(14, 144, 210\)';
  90. else if(changecolor == 'lg-fg-green') return 'rgb\(94, 185, 94\)';
  91. else if(changecolor == 'lg-fg-orange') return 'rgb\(230, 126 34\)';
  92. else if(changecolor == 'lg-fg-red') return 'rgb\(231, 76, 60\)';
  93. else if(changecolor == 'lg-fg-purple') return 'rgb\(142, 68, 173\)';
  94. else if(changecolor == 'lg-fg-brown') return 'rgb\(173, 139, 0\)';
  95. }
  96.  
  97. if(getcookie('version') != '1.4.3'){
  98. const time = new Date();
  99. time.setDate(time.getDate() + 1919810);
  100. document.cookie = "version=1.4.3" + ";expires=" + time.toUTCString();
  101. alert('new luogu 1.4.3!');
  102. alert('更新:1.在每个页面都能显示图标(除了专栏)');
  103. alert('bug:只能在主页互动,因为在其他页面更改不会生效');
  104. }
  105.  
  106. let changecolor = getcookie('color');
  107.  
  108. let tagchange = getcookie('tag');
  109. let tag = document.createElement("span");
  110. let tagcolor;
  111. if(changecolor != 'lg-fg-blue' && changecolor != 'lg-fg-orange'){
  112. tagcolor = changecolor.replace('fg','bg');
  113. tag.className = 'am-badge am-radius ' + tagcolor;
  114. }
  115. else if(changecolor == 'lg-fg-blue'){
  116. tagcolor = 'color-none';
  117. tag.className = 'am-badge am-radius ' + tagcolor;
  118. tag.style.background = 'rgb(52, 152, 219)';
  119. }
  120. else if(changecolor == 'lg-fg-orange'){
  121. tagcolor = 'color-none';
  122. tag.className = 'am-badge am-radius ' + tagcolor;
  123. tag.style.background = 'rgb(243, 156, 17)';
  124. }
  125. if(changecolor != 'lg-fg-brown') tag.textContent = tagchange;
  126. else tag.textContent = '作弊者';
  127.  
  128. //首页
  129. if(nowurl == 'https://www.luogu.com.cn/'){
  130. //日历
  131. const today=new Date();
  132. const year=today.getFullYear();
  133. const month=String(today.getMonth()+1);
  134. const day=String(today.getDate());
  135. console.log(year);
  136. console.log(month);
  137. console.log(day);
  138. let date_html='<h2>今天是 '+year+'-'+month+'-'+day+'</h2>';
  139. if(month==1&&day==1){
  140. date_html+='<h2>今天是元旦,新的一年,新的开始</h2>';
  141. }
  142. else if(month==2&&day==29){
  143. date_html+='<h2>今年是闰年</h2>';
  144. }
  145. else if(month==4&&day==1){
  146. date_html+='<h2>今天是愚人节</h2>';
  147. }
  148. else if(month==5&&day==1){
  149. date_html+='<h2>今天是劳动节</h2>';
  150. }
  151. else if(month==6&&day==1){
  152. date_html+='<h2>今天是儿童节</h2>';
  153. }
  154. else if(month==9&&day==10){
  155. date_html+='<h2>今天是教师节</h2>';
  156. }
  157. else if(month==10&&day==1){
  158. date_html+='<h2>今天是国庆节,七天小长假,启动!</h2>'
  159. }
  160. else if(month==12&&day==31){
  161. date_html+='<h2>明年见</h2>';
  162. }
  163. else{
  164. date_html+='<h2>欢迎!</h2>';
  165. }
  166. let date = document.createElement('div');
  167. date.className = 'lg-article';
  168. date.innerHTML = date_html;
  169. document.querySelector('div.lg-right > div:nth-child(1)').insertAdjacentElement('beforebegin', date);
  170.  
  171. //更改用户名颜色
  172. 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');
  173. console.log(color);
  174. if(changecolor != 'null') color.className=changecolor;
  175.  
  176. function removeDivWithText(text) {
  177. document.querySelectorAll('div').forEach(div => {
  178. if(div.textContent === text) div.remove();
  179. });
  180. }
  181.  
  182. function findElement(element, text, cclass){
  183. document.querySelectorAll(element).forEach(E => {
  184. if(E.textContent === text) E.className = cclass;
  185. });
  186. }
  187.  
  188. removeDivWithText('暂无推荐');
  189. removeDivWithText('洛谷根据您近期的做题情况,使用机器学习自动为您推荐符合您目前程度的题目。本列表每日更新一次。');
  190.  
  191. GM_xmlhttpRequest({
  192. method: "GET",
  193. url: 'https://top.baidu.com/board?tab=realtime',
  194. onload: function(response){
  195. let rs = new DOMParser();
  196. let doc = rs.parseFromString(response.responseText, "text/html");
  197. for(let i=1;i<=5;i++){
  198. let th = i.toString();
  199. 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';
  200. let _rs = doc.querySelector(selector);
  201. console.log(_rs.textContent);
  202. let selector2 = '#sanRoot > main > div.container.right-container_2EFJr > div > div:nth-child(2) > div:nth-child(' + th + ') > div.content_1YWBm > a';
  203. let rslink = doc.querySelector(selector2);
  204. console.log(rslink);
  205. let link = document.createElement("a");
  206. link.href = rslink.href;
  207. link.textContent = _rs.textContent;
  208. let RS = document.createElement("p");
  209. RS.appendChild(link);
  210. findElement('h2','智能推荐','zntj');
  211. document.getElementsByClassName('zntj')[0].parentNode.append(RS);
  212. }
  213. }
  214. });
  215. }
  216.  
  217. window.onload = function(){
  218. let _hanger = getcookie('hanger');
  219. let __hanger = document.createElementNS('http://www.w3.org/2000/svg','svg');
  220. __hanger.setAttribute('width','16');
  221. __hanger.setAttribute('height','16');
  222. __hanger.setAttribute('viewBox','0 0 16 16');
  223. __hanger.setAttribute('style','margin-bottom: -3px;');
  224.  
  225. if(_hanger == 'green') __hanger.setAttribute('fill','#5eb95e');
  226. else if(_hanger == 'blue') __hanger.setAttribute('fill','#3498db');
  227. else if(_hanger == 'golden') __hanger.setAttribute('fill','#f1c40f');
  228.  
  229. let ___hanger = document.createElementNS('http://www.w3.org/2000/svg','path');
  230. ___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');
  231. __hanger.appendChild(___hanger);
  232. let _hanger_ = document.createElement("a");
  233. _hanger_.href = 'https://www.luogu.com/discuss/142324';
  234. _hanger_.appendChild(__hanger);
  235.  
  236. let button = document.createElement("div");
  237. 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>';
  238. let menu = document.createElement("div");
  239. menu.innerHTML = '<div class=\"newlgmenu\"><from class=\"NEWLG-menu\"><h2>v1.3.0</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>';
  240. 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'))){
  241. document.querySelector('#app > div.main-container > div.wrapper.wrapped.lfe-body.header-layout.tiny > div.container > nav').insertAdjacentElement('beforebegin', button);
  242. document.querySelector("#app > div.main-container > div.wrapper.wrapped.lfe-body.header-layout.tiny > div.container").parentNode.append(menu);
  243. }
  244. else{
  245. let user_nav = document.querySelector('div.user-nav[data-v-2dfcfd35]');
  246. user_nav.insertBefore(button,user_nav.firstChild);
  247. }
  248. const tb = document.getElementById("NLTB");
  249. let menudisplay = document.getElementsByClassName("newlgmenu")[0];
  250.  
  251. function reloadmenu(){
  252. location.reload();
  253. menudisplay.style.display = 'flex';
  254. document.body.style.overflow = 'hidden';
  255. tb.textContent = "EXIT";
  256. }
  257.  
  258. tb.addEventListener('click', function(){
  259. if(menudisplay.style.display == 'none'){
  260. menudisplay.style.display = 'flex';
  261. document.body.style.overflow = 'hidden';
  262. tb.textContent = "EXIT";
  263. }
  264. else{
  265. menudisplay.style.display = 'none';
  266. document.body.style.overflow = 'visible';
  267. tb.textContent = "NEWLG";
  268. }
  269.  
  270. const submitcolor = document.getElementById('submitcolor');
  271. const greenhanger = document.getElementById('greenhanger');
  272. const bluehanger = document.getElementById('bluehanger');
  273. const goldenhanger = document.getElementById('goldenhanger');
  274. const nullhanger = document.getElementById('nullhanger');
  275.  
  276. submitcolor.addEventListener('click', function(){
  277. let colorchange = document.getElementById('nlcolor').value;
  278. console.log(colorchange);
  279. deletecookie('color');
  280. if(colorchange=='灰名'||colorchange=='gray'){
  281. const time = new Date();
  282. time.setDate(time.getDate() + 365);
  283. document.cookie = "color=lg-fg-gray" + ";expires=" + time.toUTCString();
  284. reloadmenu();
  285. }
  286. else if(colorchange=='蓝名'||colorchange=='blue'){
  287. const time = new Date();
  288. time.setDate(time.getDate() + 365);
  289. document.cookie = "color=lg-fg-blue" + ";expires=" + time.toUTCString();
  290. reloadmenu();
  291. }
  292. else if(colorchange=='绿名'||colorchange=='green'){
  293. const time = new Date();
  294. time.setDate(time.getDate() + 365);
  295. document.cookie = "color=lg-fg-green" + ";expires=" + time.toUTCString();
  296. reloadmenu();
  297. }
  298. else if(colorchange=='橙名'||colorchange=='orange'){
  299. const time = new Date();
  300. time.setDate(time.getDate() + 365);
  301. document.cookie = "color=lg-fg-orange" + ";expires=" + time.toUTCString();
  302. reloadmenu();
  303. }
  304. else if(colorchange=='红名'||colorchange=='red'){
  305. const time = new Date();
  306. time.setDate(time.getDate() + 365);
  307. document.cookie = "color=lg-fg-red" + ";expires=" + time.toUTCString();
  308. reloadmenu();
  309. }
  310. else if(colorchange=='紫名'||colorchange=='purple'){
  311. const time = new Date();
  312. time.setDate(time.getDate() + 365);
  313. document.cookie = "color=lg-fg-purple" + ";expires=" + time.toUTCString();
  314. reloadmenu();
  315. }
  316. else if(colorchange=='棕名'||colorchange=='brown'){
  317. const time = new Date();
  318. time.setDate(time.getDate() + 365);
  319. document.cookie = "color=lg-fg-brown" + ";expires=" + time.toUTCString();
  320. reloadmenu();
  321. }
  322. else if(colorchange=='复原'||colorchange=='recover'){
  323. const time = new Date();
  324. time.setDate(time.getDate() + 365);
  325. document.cookie = "color=" + nowcolor + ";expires=" + time.toUTCString();
  326. reloadmenu();
  327. }
  328. else alert('请按规范输入');
  329. });
  330. greenhanger.addEventListener('click', function(){
  331. deletecookie('hanger');
  332. const time = new Date();
  333. time.setDate(time.getDate() + 365);
  334. document.cookie = "hanger=green" + ";expires=" + time.toUTCString();
  335. reloadmenu();
  336. });
  337. bluehanger.addEventListener('click', function(){
  338. deletecookie('hanger');
  339. const time = new Date();
  340. time.setDate(time.getDate() + 365);
  341. document.cookie = "hanger=blue" + ";expires=" + time.toUTCString();
  342. reloadmenu();
  343. });
  344. goldenhanger.addEventListener('click', function(){
  345. deletecookie('hanger');
  346. const time = new Date();
  347. time.setDate(time.getDate() + 365);
  348. document.cookie = "hanger=golden" + ";expires=" + time.toUTCString();
  349. reloadmenu();
  350. });
  351. nullhanger.addEventListener('click',function(){
  352. deletecookie('hanger');
  353. const time = new Date();
  354. time.setDate(time.getDate() + 365);
  355. document.cookie = "hanger=null" + ";expires=" + time.toUTCString();
  356. reloadmenu();
  357. });
  358.  
  359. const submittag = document.getElementById('submittag');
  360. submittag.addEventListener('click', function(){
  361. let tagchange = document.getElementById('nltag').value;
  362. if(getcookie('color') == 'lg-fg-brown') alert('当前为棕名');
  363. else if(tagchange.length > 10) alert('长度应小于等于10');
  364. else{
  365. deletecookie('hanger');
  366. const time = new Date();
  367. time.setDate(time.getDate() + 365);
  368. document.cookie = "tag=" + tagchange + ";expires=" + time.toUTCString();
  369. reloadmenu();
  370. }
  371. });
  372. });
  373. if(nowurl == 'https://www.luogu.com.cn/'){
  374. if(getcookie('hanger')!='null'){
  375. 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;';
  376. 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_);
  377. }
  378. if(getcookie('tag')!='null'){
  379. 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;';
  380. 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);
  381. }
  382. }
  383. else if(nowurl.includes('https://www.luogu.com.cn/user/')&&!nowurl.includes('https://www.luogu.com.cn/user/setting')){
  384. 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');
  385. else document.querySelector('#app > div.main-container > main > div > div.full-container > section.main > div > div:nth-child(2)').remove();
  386. let jieshao = document.querySelector('#app > div.main-container > main > div > div.full-container > section.main > div > div.introduction.marked');
  387. if(jieshao.style.display == 'none') jieshao.removeAttribute('style');
  388. }
  389. };
  390. })();