new luogu

Luogu Expansion

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

  1. // ==UserScript==
  2. // @name new luogu
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.0.1
  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. // @license MIT
  20. // ==/UserScript==
  21.  
  22. (function() {
  23. 'use strict';
  24. //进入插件
  25. console.log("This is new luogu");
  26. console.log("\n _____ _____ _____ _____ _____ \n /\\ \\ /\\ \\ /\\ \\ /\\ \\ /\\ \\ \n /::\\____\\ /::\\ \\ /::\\____\\ /::\\____\\ /::\\ \\ \n /::::| | /::::\\ \\ /:::/ / /:::/ / /::::\\ \\ \n /:::::| | /::::::\\ \\ /:::/ _/___ /:::/ / /::::::\\ \\ \n /::::::| | /:::/\\:::\\ \\ /:::/ /\\ \\ /:::/ / /:::/\\:::\\ \\ \n /:::/|::| | /:::/__\\:::\\ \\ /:::/ /::\\____\\ /:::/ / /:::/ \\:::\\ \\ \n /:::/ |::| | /::::\\ \\:::\\ \\ /:::/ /:::/ / /:::/ / /:::/ \\:::\\ \\ \n /:::/ |::| | _____ /::::::\\ \\:::\\ \\ /:::/ /:::/ _/___ /:::/ / /:::/ / \\:::\\ \\ \n /:::/ |::| |/\\ \\ /:::/\\:::\\ \\:::\\ \\ /:::/___/:::/ /\\ \\ /:::/ / /:::/ / \\:::\\ ___\\ \n/:: / |::| /::\\____\\/:::/__\\:::\\ \\:::\\____\\|:::| /:::/ /::\\____\\/:::/____/ /:::/____/ ___\\:::| |\n\\::/ /|::| /:::/ /\\:::\\ \\:::\\ \\::/ /|:::|__/:::/ /:::/ /\\:::\\ \\ \\:::\\ \\ /\\ /:::|____|\n \\/____/ |::| /:::/ / \\:::\\ \\:::\\ \\/____/ \\:::\\/:::/ /:::/ / \\:::\\ \\ \\:::\\ /::\\ \\::/ / \n |::|/:::/ / \\:::\\ \\:::\\ \\ \\::::::/ /:::/ / \\:::\\ \\ \\:::\\ \\:::\\ \\/____/ \n |::::::/ / \\:::\\ \\:::\\____\\ \\::::/___/:::/ / \\:::\\ \\ \\:::\\ \\:::\\____\\ \n |:::::/ / \\:::\\ \\::/ / \\:::\\__/:::/ / \\:::\\ \\ \\:::\\ /:::/ / \n |::::/ / \\:::\\ \\/____/ \\::::::::/ / \\:::\\ \\ \\:::\\/:::/ / \n /:::/ / \\:::\\ \\ \\::::::/ / \\:::\\ \\ \\::::::/ / \n /:::/ / \\:::\\____\\ \\::::/ / \\:::\\____\\ \\::::/ / \n \\::/ / \\::/ / \\::/____/ \\::/ / \\::/____/ \n \\/____/ \\/____/ ~~ \\/____/ \n ");
  27.  
  28. var css = ".newlgmenu{width: 100vw; height: 100vh; display: none; align-items: center; justify-content: center; } .NEWLG-menu{width: 600px; height: 400px; 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; }";
  29. var style = document.createElement("style");
  30. style.innerHTML = css;
  31. document.head.appendChild(style);
  32.  
  33. let nowurl = window.location.href;
  34. console.log(nowurl);
  35.  
  36. function getcookie(name){
  37. const cookiestring = document.cookie;
  38. const cookies = cookiestring.split('; ');
  39. for(const cookie of cookies){
  40. const [cookiename, cookievalue] = cookie.split('=');
  41. if(cookiename === name) return cookievalue;
  42. }
  43. const time = new Date();
  44. time.setDate(time.getDate() + 365);
  45. document.cookie = "color=null" + ";expires=" + time.toUTCString();
  46. return "null";
  47. }
  48.  
  49. //首页
  50. if(nowurl == 'https://www.luogu.com.cn/'){
  51. //日历
  52. const today=new Date();
  53. const year=today.getFullYear();
  54. const month=String(today.getMonth()+1);
  55. const day=String(today.getDate());
  56. console.log(year);
  57. console.log(month);
  58. console.log(day);
  59. let date_html='<h2>今天是 '+year+'-'+month+'-'+day+'</h2>';
  60. if(month==1&&day==1){
  61. date_html+='<h2>今天是元旦,新的一年,新的开始</h2>';
  62. }
  63. else if(month==2&&day==29){
  64. date_html+='<h2>今年是闰年</h2>';
  65. }
  66. else if(month==4&&day==1){
  67. date_html+='<h2>今天是愚人节</h2>';
  68. }
  69. else if(month==5&&day==1){
  70. date_html+='<h2>今天是劳动节</h2>';
  71. }
  72. else if(month==6&&day==1){
  73. date_html+='<h2>今天是儿童节</h2>';
  74. }
  75. else if(month==9&&day==10){
  76. date_html+='<h2>今天是教师节</h2>';
  77. }
  78. else if(month==10&&day==1){
  79. date_html+='<h2>今天是国庆节,七天小长假,启动!</h2>'
  80. }
  81. else if(month==12&&day==31){
  82. date_html+='<h2>明年见</h2>';
  83. }
  84. else if(month==4&&day==28){
  85. let years=year-2012;
  86. date_html+='<h2>今天是作者生日的后 '+years+' 年</h2>';
  87. }
  88. else{
  89. date_html+='<h2>欢迎!</h2>';
  90. }
  91. let date = document.createElement('div');
  92. date.className = 'lg-article';
  93. date.innerHTML = date_html;
  94. document.querySelector('div.lg-right > div:nth-child(1)').insertAdjacentElement('beforebegin', date);
  95.  
  96. //更改用户名颜色
  97. 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');
  98. let changecolor = getcookie('color');
  99. console.log(color);
  100. if(changecolor != 'null') color.className=changecolor;
  101.  
  102. //介绍
  103. let x=[{link:'https://github.com/zhuangjihong/new-luogu',text:'GITHUB'},];
  104. setTimeout(
  105. function(){
  106. for(let i in x){
  107. let a=document.createElement("a");
  108. document.querySelectorAll('.link-container')[0].append(a);
  109. a.outerHTML='<a href=\"'+x[i].link+'\" target=\"_blank\" colorscheme=\"none\" class=\"header-link color-none\" style="vertical-align: middle;margin-right: 2em;color: #262626;text-decoration: none;">'+x[i].text+'</a>';
  110. }
  111. },100
  112. );
  113.  
  114. 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)').remove();
  115. 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(4)').remove();
  116. 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 > small').remove();
  117. }
  118.  
  119. window.onload = function(){
  120. let button = document.createElement("div");
  121. 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>';
  122. 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);
  123. let menu = document.createElement("div");
  124. menu.innerHTML = '<div class=\"newlgmenu\"><from class=\"NEWLG-menu\"><h2>v1.0.1</h2><h3>用户名颜色</h3><input type="text" value="更改名字颜色为(如“紫名”“复原”)" id="nlcolor"><button>提交</button></from></div>';
  125. document.querySelector("#app > div.main-container > div.wrapper.wrapped.lfe-body.header-layout.tiny > div.container").parentNode.append(menu);
  126. const tb = document.querySelector('#app > div.main-container > div.wrapper.wrapped.lfe-body.header-layout.tiny > div.container > div:nth-child(3) > button');
  127. tb.addEventListener('click', function(){
  128. let menudisplay = document.querySelector('#app > div.main-container > div.wrapper.wrapped.lfe-body.header-layout.tiny > div:nth-child(3) > div');
  129. if(menudisplay.style.display === 'none') menudisplay.style.display = 'flex';
  130. else menudisplay.style.display = 'none';
  131.  
  132. const submitcolor = document.querySelector('#app > div.main-container > div.wrapper.wrapped.lfe-body.header-layout.tiny > div:nth-child(3) > div > from > button');
  133. submitcolor.addEventListener('click', function(){
  134. let colorchange = document.getElementById('nlcolor').value;
  135. console.log(colorchange);
  136. if(colorchange=='灰名'){
  137. const time = new Date();
  138. time.setDate(time.getDate() + 365);
  139. document.cookie = "color=lg-fg-gray" + ";expires=" + time.toUTCString();
  140. location.reload();
  141. }
  142. else if(colorchange=='蓝名'){
  143. const time = new Date();
  144. time.setDate(time.getDate() + 365);
  145. document.cookie = "color=lg-fg-blue" + ";expires=" + time.toUTCString();
  146. location.reload();
  147. }
  148. else if(colorchange=='绿名'){
  149. const time = new Date();
  150. time.setDate(time.getDate() + 365);
  151. document.cookie = "color=lg-fg-green" + ";expires=" + time.toUTCString();
  152. location.reload();
  153. }
  154. else if(colorchange=='橙名'){
  155. const time = new Date();
  156. time.setDate(time.getDate() + 365);
  157. document.cookie = "color=lg-fg-orange" + ";expires=" + time.toUTCString();
  158. location.reload();
  159. }
  160. else if(colorchange=='红名'){
  161. const time = new Date();
  162. time.setDate(time.getDate() + 365);
  163. document.cookie = "color=lg-fg-red" + ";expires=" + time.toUTCString();
  164. location.reload();
  165. }
  166. else if(colorchange=='紫名'){
  167. const time = new Date();
  168. time.setDate(time.getDate() + 365);
  169. document.cookie = "color=lg-fg-purple" + ";expires=" + time.toUTCString();
  170. location.reload();
  171. }
  172. else if(colorchange=='复原'){
  173. const time = new Date();
  174. time.setDate(time.getDate() + 365);
  175. document.cookie = "color=null" + ";expires=" + time.toUTCString();
  176. location.reload();
  177. }
  178. });
  179. });
  180. };
  181. // Your code here...
  182. })();