new luogu

洛谷扩展

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

  1. // ==UserScript==
  2. // @name new luogu
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.0.0
  5. // @description 洛谷扩展
  6. // @author volatile
  7. // @match https://*.luogu.com.cn/*
  8. // @match https://*.luogu.org/*
  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.  
  27. //日历
  28. const today=new Date();
  29. const year=today.getFullYear();
  30. const month=String(today.getMonth()+1);
  31. const day=String(today.getDate());
  32. console.log(year);
  33. console.log(month);
  34. console.log(day);
  35. var date_html=`<h2>今天是 `+year+`-`+month+`-`+day+`</h2>`;
  36. if(month==1&&day==1){
  37. date_html+=`<h2>今天是元旦,新的一年,新的开始</h2>`;
  38. }
  39. else if(month==2&&day==29){
  40. date_html+=`<h2>今年是闰年</h2>`;
  41. }
  42. else if(month==4&&day==1){
  43. date_html+=`<h2>今天是愚人节</h2>`;
  44. }
  45. else if(month==5&&day==1){
  46. date_html+=`<h2>今天是劳动节</h2>`;
  47. }
  48. else if(month==6&&day==1){
  49. date_html+=`<h2>今天是儿童节</h2>`;
  50. }
  51. else if(month==9&&day==10){
  52. date_html+=`<h2>今天是教师节</h2>`;
  53. }
  54. else if(month==10&&day==1){
  55. date_html+=`<h2>今天是国庆节,七天小长假,启动!</h2>`
  56. }
  57. else if(month==12&&day==31){
  58. date_html+=`<h2>明年见</h2>`;
  59. }
  60. else if(month==4&&day==28){
  61. var years=year-2012;
  62. date_html+=`<h2>今天是作者生日的后 `+years+` 年</h2>`;
  63. }
  64. else{
  65. date_html+=`<h2>欢迎!</h2>`;
  66. }
  67. var date=document.createElement('div');
  68. date.className='lg-article';
  69. date.innerHTML=date_html;
  70. document.querySelector('div.lg-right > div:nth-child(1)').insertAdjacentElement('beforebegin', date);
  71.  
  72. //更改用户名颜色
  73. var color=document.getElementsByClassName("lg-fg-green")[0];
  74. console.log(color);
  75. color.className="lg-fg-purple";
  76.  
  77. //介绍
  78. var x=[{link:'https://github.com/zhuangjihong/new-luogu',text:'NEWLG'},];
  79. function add()
  80. {
  81. if(document.querySelectorAll('.link-container')[0]==undefined){
  82. setTimeout(function(){add()},50);
  83. }
  84. else{
  85. setTimeout(function(){for(var i in x){
  86. var a=document.createElement("a");document.querySelectorAll('.link-container')[0].append(a);
  87. a.outerHTML=
  88. '<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>'
  89. ;}},100);
  90. }
  91. }
  92. add();
  93. // Your code here...
  94. })();