new luogu

Luogu Expansion

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

  1. // ==UserScript==
  2. // @name new luogu
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.3.2
  5. // @description Luogu Expansion
  6. // @description:zh 洛谷扩展
  7. // @author volatile
  8. // @match https://www.luogu.com.cn/*
  9. // @icon https://www.google.com/s2/favicons?sz=64&domain=luogu.com.cn
  10. // @grant GM_addStyle
  11. // @grant GM_getValue
  12. // @grant GM_setValue
  13. // @grant GM_deleteValue
  14. // @grant GM_listValues
  15. // @grant GM_setClipboard
  16. // @grant GM_xmlhttpRequest
  17. // @grant GM_getResourceText
  18. // @grant unsafeWindow
  19. // @connect baidu.com
  20. // @license MIT
  21. // ==/UserScript==
  22.  
  23. (function() {
  24. 'use strict';
  25. //进入插件
  26. console.log("This is new luogu");
  27. console.log("\n _____ _____ _____ _____ _____ \n /\\ \\ /\\ \\ /\\ \\ /\\ \\ /\\ \\ \n /::\\____\\ /::\\ \\ /::\\____\\ /::\\____\\ /::\\ \\ \n /::::| | /::::\\ \\ /:::/ / /:::/ / /::::\\ \\ \n /:::::| | /::::::\\ \\ /:::/ _/___ /:::/ / /::::::\\ \\ \n /::::::| | /:::/\\:::\\ \\ /:::/ /\\ \\ /:::/ / /:::/\\:::\\ \\ \n /:::/|::| | /:::/__\\:::\\ \\ /:::/ /::\\____\\ /:::/ / /:::/ \\:::\\ \\ \n /:::/ |::| | /::::\\ \\:::\\ \\ /:::/ /:::/ / /:::/ / /:::/ \\:::\\ \\ \n /:::/ |::| | _____ /::::::\\ \\:::\\ \\ /:::/ /:::/ _/___ /:::/ / /:::/ / \\:::\\ \\ \n /:::/ |::| |/\\ \\ /:::/\\:::\\ \\:::\\ \\ /:::/___/:::/ /\\ \\ /:::/ / /:::/ / \\:::\\ ___\\ \n/:: / |::| /::\\____\\/:::/__\\:::\\ \\:::\\____\\|:::| /:::/ /::\\____\\/:::/____/ /:::/____/ ___\\:::| |\n\\::/ /|::| /:::/ /\\:::\\ \\:::\\ \\::/ /|:::|__/:::/ /:::/ /\\:::\\ \\ \\:::\\ \\ /\\ /:::|____|\n \\/____/ |::| /:::/ / \\:::\\ \\:::\\ \\/____/ \\:::\\/:::/ /:::/ / \\:::\\ \\ \\:::\\ /::\\ \\::/ / \n |::|/:::/ / \\:::\\ \\:::\\ \\ \\::::::/ /:::/ / \\:::\\ \\ \\:::\\ \\:::\\ \\/____/ \n |::::::/ / \\:::\\ \\:::\\____\\ \\::::/___/:::/ / \\:::\\ \\ \\:::\\ \\:::\\____\\ \n |:::::/ / \\:::\\ \\::/ / \\:::\\__/:::/ / \\:::\\ \\ \\:::\\ /:::/ / \n |::::/ / \\:::\\ \\/____/ \\::::::::/ / \\:::\\ \\ \\:::\\/:::/ / \n /:::/ / \\:::\\ \\ \\::::::/ / \\:::\\ \\ \\::::::/ / \n /:::/ / \\:::\\____\\ \\::::/ / \\:::\\____\\ \\::::/ / \n \\::/ / \\::/ / \\::/____/ \\::/ / \\::/____/ \n \\/____/ \\/____/ ~~ \\/____/ \n ");
  28.  
  29. 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; } .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; }";
  30. var style = document.createElement("style");
  31. style.innerHTML = css;
  32. document.head.appendChild(style);
  33.  
  34. let nowurl = window.location.href;
  35. console.log(nowurl);
  36.  
  37. function getcookie(name){
  38. const cookiestring = document.cookie;
  39. const cookies = cookiestring.split('; ');
  40. for(const cookie of cookies){
  41. const [cookiename, cookievalue] = cookie.split('=');
  42. if(cookiename === name) return cookievalue;
  43. }
  44. if(name == 'color'){
  45. const time = new Date();
  46. time.setDate(time.getDate() + 365);
  47. document.cookie = "color=null" + ";expires=" + time.toUTCString();
  48. return "null";
  49. }
  50. else if(name == 'hanger'){
  51. const time = new Date();
  52. time.setDate(time.getDate() + 365);
  53. document.cookie = "hanger=null" + ";expires=" + time.toUTCString();
  54. return "null";
  55. }
  56. else if(name == 'tag'){
  57. const time = new Date();
  58. time.setDate(time.getDate() + 365);
  59. document.cookie = "tag=null" + ";expires=" + time.toUTCString();
  60. return "null";
  61. }
  62. else if(name == 'version'){
  63. const time = new Date();
  64. time.setDate(time.getDate() + 119810);
  65. document.cookie = "version=1.3.1" + ";expires=" + time.toUTCString();
  66. return "1.3.1";
  67. }
  68. }
  69.  
  70. function colorschange(changecolor){
  71. if(changecolor == 'lg-fg-gray') return 'rgb\(191, 191, 191\)';
  72. else if(changecolor == 'lg-fg-blue') return 'rgb\(14, 144, 210\)';
  73. else if(changecolor == 'lg-fg-green') return 'rgb\(94, 185, 94\)';
  74. else if(changecolor == 'lg-fg-orange') return 'rgb\(230, 126 34\)';
  75. else if(changecolor == 'lg-fg-red') return 'rgb\(231, 76, 60\)';
  76. else if(changecolor == 'lg-fg-purple') return 'rgb\(142, 68, 173\)';
  77. }
  78.  
  79. if(getcookie('version') != '1.3.2'){
  80. const time = new Date();
  81. time.setDate(time.getDate() + 1919810);
  82. document.cookie = "version=1.3.2" + ";expires=" + time.toUTCString();
  83. alert('new luogu 1.3.2!');
  84. alert('更新:1.取消颜色、勾子、tag的更改;2.按下 Alt+s 试试?');
  85. alert('bug: 更新第2条在除了主页以外地方有bug');
  86. }
  87.  
  88. let nowcolor;
  89. if(nowurl == 'https://www.luogu.com.cn/'){
  90. nowcolor = 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;
  91. }
  92. console.log(nowcolor);
  93.  
  94. let changecolor = getcookie('color');
  95.  
  96. let tagchange = getcookie('tag');
  97. let tag = document.createElement("span");
  98. let tagcolor;
  99. if(changecolor != 'lg-fg-blue' && changecolor != 'lg-fg-orange'){
  100. tagcolor = changecolor.replace('fg','bg');
  101. tag.className = 'am-badge am-radius ' + tagcolor;
  102. }
  103. else if(changecolor == 'lg-fg-blue'){
  104. tagcolor = 'color-none';
  105. tag.className = 'am-badge am-radius ' + tagcolor;
  106. tag.style.background = 'rgb(52, 152, 219)';
  107. }
  108. else if(changecolor == 'lg-fg-orange'){
  109. tagcolor = 'color-none';
  110. tag.className = 'am-badge am-radius ' + tagcolor;
  111. tag.style.background = 'rgb(243, 156, 17)';
  112. }
  113. tag.textContent = tagchange;
  114.  
  115. let search = document.createElement('div');
  116. search.className = 'search-container';
  117. let search_input = document.createElement('input');
  118. search_input.type = 'text';
  119. search_input.className = 'search-box';
  120. search_input.placeholder = 'Search...';
  121. let fdj = document.createElementNS('http://www.w3.org/2000/svg','svg');
  122. fdj.setAttribute('aria-hidden','true');
  123. fdj.setAttribute('focusable','false');
  124. fdj.setAttribute('data-prefix','fas');
  125. fdj.setAttribute('data-icon','magnifying-glass');
  126. fdj.setAttribute('role','img');
  127. fdj.setAttribute('xmlns','http://www.w3.org/2000/svg');
  128. fdj.setAttribute('viewBox','0 0 512 512');
  129. fdj.setAttribute('class','svg-inline--fa fa-magnifying-glass');
  130. fdj.setAttribute('style','position: relative; left: 205px; top: 15px;');
  131.  
  132. let fdj_path = document.createElementNS('http://www.w3.org/2000/svg','path');
  133. fdj_path.setAttribute('fill','currentColor');
  134. fdj_path.setAttribute('d','M416 208c0 45.9-14.9 88.3-40 122.7L502.6 457.4c12.5 12.5 12.5 32.8 0 45.3s-32.8 12.5-45.3 0L330.7 376c-34.4 25.2-76.8 40-122.7 40C93.1 416 0 322.9 0 208S93.1 0 208 0S416 93.1 416 208zM208 352a144 144 0 1 0 0-288 144 144 0 1 0 0 288z');
  135. fdj.appendChild(fdj_path);
  136.  
  137. search.appendChild(fdj);
  138. search.appendChild(search_input);
  139. document.body.appendChild(search);
  140.  
  141. let mask = document.createElement('div');
  142. mask.id = "mask";
  143. mask.style.display = "none";
  144. document.body.appendChild(mask);
  145. function showMask() {
  146. document.getElementById('mask').style.display = 'block';
  147. }
  148. function hideMask() {
  149. document.getElementById('mask').style.display = 'none';
  150. }
  151.  
  152. //首页
  153. if(nowurl == 'https://www.luogu.com.cn/'){
  154. //日历
  155. const today=new Date();
  156. const year=today.getFullYear();
  157. const month=String(today.getMonth()+1);
  158. const day=String(today.getDate());
  159. console.log(year);
  160. console.log(month);
  161. console.log(day);
  162. let date_html='<h2>今天是 '+year+'-'+month+'-'+day+'</h2>';
  163. if(month==1&&day==1){
  164. date_html+='<h2>今天是元旦,新的一年,新的开始</h2>';
  165. }
  166. else if(month==2&&day==29){
  167. date_html+='<h2>今年是闰年</h2>';
  168. }
  169. else if(month==4&&day==1){
  170. date_html+='<h2>今天是愚人节</h2>';
  171. }
  172. else if(month==5&&day==1){
  173. date_html+='<h2>今天是劳动节</h2>';
  174. }
  175. else if(month==6&&day==1){
  176. date_html+='<h2>今天是儿童节</h2>';
  177. }
  178. else if(month==9&&day==10){
  179. date_html+='<h2>今天是教师节</h2>';
  180. }
  181. else if(month==10&&day==1){
  182. date_html+='<h2>今天是国庆节,七天小长假,启动!</h2>'
  183. }
  184. else if(month==12&&day==31){
  185. date_html+='<h2>明年见</h2>';
  186. }
  187. else if(month==4&&day==28){
  188. let years=year-2012;
  189. date_html+='<h2>今天是作者生日的后 '+years+' 年</h2>';
  190. }
  191. else{
  192. date_html+='<h2>欢迎!</h2>';
  193. }
  194. let date = document.createElement('div');
  195. date.className = 'lg-article';
  196. date.innerHTML = date_html;
  197. document.querySelector('div.lg-right > div:nth-child(1)').insertAdjacentElement('beforebegin', date);
  198.  
  199. //更改用户名颜色
  200. 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');
  201. console.log(color);
  202. if(changecolor != 'null') color.className=changecolor;
  203.  
  204. 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(3) > div:nth-child(5)').remove();
  205. 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(3) > div').remove();
  206.  
  207. GM_xmlhttpRequest({
  208. method: "GET",
  209. url: 'https://top.baidu.com/board?tab=realtime',
  210. onload: function(response){
  211. let rs = new DOMParser();
  212. let doc = rs.parseFromString(response.responseText, "text/html");
  213. for(let i=1;i<=5;i++){
  214. let th = i.toString();
  215. 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';
  216. let _rs = doc.querySelector(selector);
  217. console.log(_rs.textContent);
  218. let selector2 = '#sanRoot > main > div.container.right-container_2EFJr > div > div:nth-child(2) > div:nth-child(' + th + ') > div.content_1YWBm > a';
  219. let rslink = doc.querySelector(selector2);
  220. console.log(rslink);
  221. let link = document.createElement("a");
  222. link.href = rslink.href;
  223. link.textContent = _rs.textContent;
  224. let RS = document.createElement("p");
  225. RS.appendChild(link);
  226. 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(3) > h2:nth-child(4)').parentNode.append(RS);
  227. }
  228. }
  229. });
  230. }
  231.  
  232. window.onload = function(){
  233. let _hanger = getcookie('hanger');
  234. let __hanger = document.createElementNS('http://www.w3.org/2000/svg','svg');
  235. __hanger.setAttribute('width','16');
  236. __hanger.setAttribute('height','16');
  237. __hanger.setAttribute('viewBox','0 0 16 16');
  238. __hanger.setAttribute('style','margin-bottom: -3px;');
  239.  
  240. if(_hanger == 'green') __hanger.setAttribute('fill','#5eb95e');
  241. else if(_hanger == 'blue') __hanger.setAttribute('fill','#3498db');
  242. else if(_hanger == 'golden') __hanger.setAttribute('fill','#f1c40f');
  243.  
  244. let ___hanger = document.createElementNS('http://www.w3.org/2000/svg','path');
  245. ___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');
  246. __hanger.appendChild(___hanger);
  247. let _hanger_ = document.createElement("a");
  248. _hanger_.href = 'https://www.luogu.com/discuss/142324';
  249. _hanger_.appendChild(__hanger);
  250.  
  251. let button = document.createElement("div");
  252. button.innerHTML = '<button 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>';
  253. 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'))) document.querySelector('#app > div.main-container > div.wrapper.wrapped.lfe-body.header-layout.tiny > div.container > nav').insertAdjacentElement('beforebegin', button);
  254. let menu = document.createElement("div");
  255. menu.innerHTML = '<div class=\"newlgmenu\"><from class=\"NEWLG-menu\"><h2>v1.3.0</h2><h3>用户名颜色</h3><input type="text" placeholder="更改名字颜色为(如“紫名”“复原”)" id="nlcolor"><button>提交</button><h3>勾子<h3><button><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><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><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><svg xmlns="http://www.w3.org/2000/svg" width="50" height="50" viewBox="0 0 50 50" overflow="visible" stroke="black" 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="键入 null 以取消"><button>提交</button></from></div>';
  256. document.querySelector("#app > div.main-container > div.wrapper.wrapped.lfe-body.header-layout.tiny > div.container").parentNode.append(menu);
  257. const tb = document.querySelector('#app > div.main-container > div.wrapper.wrapped.lfe-body.header-layout.tiny > div.container > div:nth-child(3) > button');
  258. tb.addEventListener('click', function(){
  259. let menudisplay = document.querySelector('#app > div.main-container > div.wrapper.wrapped.lfe-body.header-layout.tiny > div:nth-child(3) > div');
  260. if(menudisplay.style.display == 'none'){
  261. menudisplay.style.display = 'flex';
  262. document.body.style.overflow = 'hidden';
  263. tb.textContent = "EXIT";
  264. }
  265. else{
  266. menudisplay.style.display = 'none';
  267. document.body.style.overflow = 'visible';
  268. tb.textContent = "NEWLG";
  269. }
  270.  
  271. const submitcolor = document.querySelector('#app > div.main-container > div.wrapper.wrapped.lfe-body.header-layout.tiny > div:nth-child(3) > div > from > button');
  272. const greenhanger = document.querySelector('#app > div.main-container > div.wrapper.wrapped.lfe-body.header-layout.tiny > div:nth-child(3) > div > from > h3:nth-child(6) > button:nth-child(1)');
  273. const bluehanger = document.querySelector('#app > div.main-container > div.wrapper.wrapped.lfe-body.header-layout.tiny > div:nth-child(3) > div > from > h3:nth-child(6) > button:nth-child(2)');
  274. const goldenhanger = document.querySelector('#app > div.main-container > div.wrapper.wrapped.lfe-body.header-layout.tiny > div:nth-child(3) > div > from > h3:nth-child(6) > button:nth-child(3)');
  275. const nullhanger = document.querySelector('#app > div.main-container > div.wrapper.wrapped.lfe-body.header-layout.tiny > div:nth-child(3) > div > from > h3:nth-child(6) > button:nth-child(4)');
  276.  
  277. submitcolor.addEventListener('click', function(){
  278. let colorchange = document.getElementById('nlcolor').value;
  279. console.log(colorchange);
  280. if(colorchange=='灰名'){
  281. const time = new Date();
  282. time.setDate(time.getDate() + 365);
  283. document.cookie = "color=lg-fg-gray" + ";expires=" + time.toUTCString();
  284. location.reload();
  285. }
  286. else if(colorchange=='蓝名'){
  287. const time = new Date();
  288. time.setDate(time.getDate() + 365);
  289. document.cookie = "color=lg-fg-blue" + ";expires=" + time.toUTCString();
  290. location.reload();
  291. }
  292. else if(colorchange=='绿名'){
  293. const time = new Date();
  294. time.setDate(time.getDate() + 365);
  295. document.cookie = "color=lg-fg-green" + ";expires=" + time.toUTCString();
  296. location.reload();
  297. }
  298. else if(colorchange=='橙名'){
  299. const time = new Date();
  300. time.setDate(time.getDate() + 365);
  301. document.cookie = "color=lg-fg-orange" + ";expires=" + time.toUTCString();
  302. location.reload();
  303. }
  304. else if(colorchange=='红名'){
  305. const time = new Date();
  306. time.setDate(time.getDate() + 365);
  307. document.cookie = "color=lg-fg-red" + ";expires=" + time.toUTCString();
  308. location.reload();
  309. }
  310. else if(colorchange=='紫名'){
  311. const time = new Date();
  312. time.setDate(time.getDate() + 365);
  313. document.cookie = "color=lg-fg-purple" + ";expires=" + time.toUTCString();
  314. location.reload();
  315. }
  316. else if(colorchange=='复原'){
  317. const time = new Date();
  318. time.setDate(time.getDate() + 365);
  319. document.cookie = "color=null" + ";expires=" + time.toUTCString();
  320. location.reload();
  321. }
  322. });
  323. greenhanger.addEventListener('click', function(){
  324. const time = new Date();
  325. time.setDate(time.getDate() + 365);
  326. document.cookie = "hanger=green" + ";expires=" + time.toUTCString();
  327. location.reload();
  328. });
  329. bluehanger.addEventListener('click', function(){
  330. const time = new Date();
  331. time.setDate(time.getDate() + 365);
  332. document.cookie = "hanger=blue" + ";expires=" + time.toUTCString();
  333. location.reload();
  334. });
  335. goldenhanger.addEventListener('click', function(){
  336. const time = new Date();
  337. time.setDate(time.getDate() + 365);
  338. document.cookie = "hanger=golden" + ";expires=" + time.toUTCString();
  339. location.reload();
  340. });
  341. nullhanger.addEventListener('click',function(){
  342. const time = new Date();
  343. time.setDate(time.getDate() + 365);
  344. document.cookie = "hanger=null" + ";expires=" + time.toUTCString();
  345. location.reload();
  346. });
  347.  
  348. const submittag = document.querySelector('#app > div.main-container > div.wrapper.wrapped.lfe-body.header-layout.tiny > div:nth-child(3) > div > from > button:nth-child(9)');
  349. submittag.addEventListener('click', function(){
  350. let tagchange = document.getElementById('nltag').value;
  351. const time = new Date();
  352. time.setDate(time.getDate() + 365);
  353. document.cookie = "tag=" + tagchange + ";expires=" + time.toUTCString();
  354. location.reload();
  355. });
  356. });
  357. if(nowurl == 'https://www.luogu.com.cn/'){
  358. if(getcookie('hanger')!='null'){
  359. 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;';
  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').appendChild(_hanger_);
  361. }
  362. if(getcookie('tag')!='null'){
  363. 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;';
  364. 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);
  365. }
  366. }
  367. else if(nowurl.includes('https://www.luogu.com.cn/user/')&&!nowurl.includes('https://www.luogu.com.cn/user/setting')){
  368. 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');
  369. else document.querySelector('#app > div.main-container > main > div > div.full-container > section.main > div > div:nth-child(2)').remove();
  370. let jieshao = document.querySelector('#app > div.main-container > main > div > div.full-container > section.main > div > div.introduction.marked');
  371. if(jieshao.style.display == 'none') jieshao.removeAttribute('style');
  372. }
  373. document.addEventListener('keydown', function(event){
  374. if(event.altKey && event.key == 's'){
  375. if(search.style.display == 'none'){
  376. search.style.display = 'flex';
  377. showMask();
  378. }
  379. else{
  380. search.style.display = 'none';
  381. hideMask();
  382. }
  383. }
  384. });
  385. fdj.addEventListener('click', function(){
  386. let sr = document.querySelector('#app > div.main-container > div.wrapper.wrapped.lfe-body.header-layout.tiny > div.container > div.search-container > input').value;
  387. if(sr!="") window.open('https://www.baidu.com/s?wd=' + sr,'_blank');
  388. });
  389. };
  390. })();