GDFZOJ返回列表

增加返回列表按钮

  1. // ==UserScript==
  2. // @name GDFZOJ返回列表
  3. // @version 1.3
  4. // @description 增加返回列表按钮
  5. // @author MlkMathew
  6. // @match *://*.gdfzoj.com*/*
  7. // @grant GM_setValue
  8. // @grant GM_getValue
  9. // @namespace https://gf.qytechs.cn/users/1068192
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14. var webs=window.location.href,id='',str;
  15. function get_last_id(nam){
  16. var dig=1,res=0;
  17. for(let i=nam.length-1;i>=0;i--)
  18. {
  19. if(nam[i]=='/'){
  20. break;
  21. }
  22. res+=dig*(nam[i]-'0');
  23. dig*=10;
  24. }
  25. return res;
  26. }
  27. function get(pid,tim){
  28. if(tim>5){
  29. return ;
  30. }
  31. $.get("http://www.gdfzoj.com:23380/exercise/"+pid,function(res){
  32. console.clear();
  33. console.log('exercise',pid,'success to catch data');
  34. for(let i=0;i+6<res.length;i++)
  35. {
  36. if(res.substr(i,7)=='problem'){
  37. var id='';
  38. for(let j=i+8;j<res.length;j++)
  39. {
  40. if(res[j]=='"'){
  41. break;
  42. }
  43. id+=res[j];
  44. }
  45. if(id==''){
  46. continue;
  47. }
  48. GM_setValue(id,pid);
  49. }
  50. }
  51. }).fail(function () {
  52. get(pid,tim+1);
  53. console.clear();
  54. console.log('exercise',pid,'failed to catch data');
  55. });
  56. }
  57. function get_exercise(num){
  58. console.log('catch data number:',num);
  59. for(let i=1;i<=num;i++)
  60. {
  61. get(i,0);
  62. }
  63. }
  64. if(!webs.substr(7,webs.length-8).match('/')){
  65. let but=document.createElement("a");
  66. but.className="btn btn-primary btn";
  67. but.textContent="爬取题单";
  68. but.style.color="rgb(255,255,255)";
  69. document.querySelector("#UOJnavbars > ul:nth-child(2) > li.nav-item.dropdown").insertAdjacentElement("beforebegin",but);
  70. but.onclick=function(){
  71. let txt=document.createElement("a");
  72. txt.textContent="正在爬取数据中...";
  73. but.insertAdjacentElement("afterend",txt);
  74. setTimeout(()=>{
  75. get_exercise(500);
  76. console.clear();
  77. console.log("success to catch data");
  78. txt.remove();
  79. },100);
  80. }
  81. return ;
  82. }
  83. const s=document.querySelectorAll('a');
  84. if(webs.match('exercise')||webs.match('problems$')){
  85. for(let i=0;i<s.length;i++)
  86. {
  87. if(s[i].href.match('problem/')){
  88. GM_setValue(get_last_id(s[i].href),get_last_id(webs));
  89. }
  90. }
  91. }
  92. if(webs.match('problem/')&&(!webs.match('contest/'))){
  93. var x;
  94. const t=document.querySelectorAll('ul');
  95. for(let i=0;i<t.length;i++)
  96. {
  97. if(t[i].role=='tablist'){
  98. x=t[i];
  99. }
  100. }
  101. var add=document.createElement("li");
  102. add.className="nav-item";
  103. var y;
  104. for(let i=0;i<s.length;i++)
  105. {
  106. if(s[i].textContent==' 提交'){
  107. y=s[i].cloneNode(true);
  108. }
  109. }
  110. y.textContent=' 返回列表';
  111. y.dataset.toggle='';
  112. y.href="http://www.gdfzoj.com:23380/exercise/"+GM_getValue(get_last_id(webs)).toString();
  113. add.insertAdjacentElement("beforeend",y);
  114. x.insertAdjacentElement("beforeend",add);
  115. }
  116. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址