SCAU OJ小工具(Beta)

适用于:SCAU华南农业大学OJ平台;

  1. // ==UserScript==
  2. // @name SCAU OJ小工具(Beta)
  3. // @namespace YelloooBlue_SCAU_OJ_TimerTool
  4. // @version 0.3
  5. // @description 适用于:SCAU华南农业大学OJ平台;
  6. // @author YelloooBlue
  7. // @match *://172.26.14.60:8000/uoj/mainMenu.html*
  8. // @match *://202.116.161.81:8000/uoj/mainMenu.html*
  9. // @match *://acm.scau.edu.cn:8000/uoj/mainMenu.html*
  10. // @match *://acm.scau.net.cn:8000/uoj/mainMenu.html*
  11. // @grant
  12. // ==/UserScript==
  13.  
  14.  
  15. var timeS = 60;//倒计时时间,可修改
  16.  
  17.  
  18. //跳转到特定提交列表
  19. function showList(code){
  20. var iframeContent_2=$('#rightMain').contents().find("iframe").contents();
  21. if(iframeContent_2.length){
  22. switch(code) {
  23. case 0:
  24. iframeContent_2.get(0).location.href="/uoj/common_solution_listAllRecent_PUBLIC.html";//OJ系统最近提交(可以看见别人)10条
  25. break;
  26. case 1:
  27. iframeContent_2.get(0).location.href="/uoj/common_solution_listByUserRecent_PUBLIC.html";//该用户最近提交记录 20条
  28. break;
  29. case 2:
  30. iframeContent_2.get(0).location.href="/uoj/common_solution_listByUser_PUBLIC.html";//该用户所有提交记录 分页
  31. break;
  32. }
  33. }else alert("请先进入实验界面")
  34. }
  35.  
  36.  
  37. //用户信息显示div
  38. var tip=$("<div id='userId' />");
  39. tip.css({"display":"inline-block","height":"50px","line-height":"50px","margin":"10px","text-align":"center","overflow":" hidden","color":"#ffffff"})
  40. var id=localStorage["userId"]
  41. var code=localStorage["userCode"]
  42. if(!id||!code)alert("小工具未读取到您的用户ID或学号,请访问“编辑个人信息”页面获取ID")
  43. tip.html("用户ID:"+id+" 学号:"+code)
  44. $("#top").prepend(tip);
  45.  
  46.  
  47. //存放跳转按钮的div
  48. var buttonDiv = $("<div />");
  49. buttonDiv.css({"display":"inline-block","height":"50px","line-height":"50px","margin":"10px","text-align":"center","overflow":" hidden"})
  50.  
  51. //三个跳转按钮
  52. var button=document.createElement("input");
  53. button.type="button";
  54. button.value="系统最近提交(所有人)";
  55. button.style="padding:5px;margin:10px";
  56. button.onclick =function(){showList(0)};
  57. buttonDiv.append(button);
  58.  
  59. button=document.createElement("input");
  60. button.type="button";
  61. button.value="用户最近提交";
  62. button.style="padding:5px;margin:10px";
  63. button.onclick =function(){showList(1)};
  64. buttonDiv.append(button);
  65.  
  66. button=document.createElement("input");
  67. button.type="button";
  68. button.value="用户历史提交";
  69. button.style="padding:5px;margin:10px";
  70. button.onclick = function(){showList(2)};
  71. buttonDiv.append(button);
  72.  
  73. $("#top").prepend(buttonDiv);
  74.  
  75.  
  76.  
  77. //倒计时显示div
  78. var div = document.createElement("div");
  79. div.style.cssText = "background: #044599;display:inline-block;color:#ffffff;overflow: hidden;z-index: 99999999;margin:10px;text-align:center;line-height:50px;width: 50px;height: 50px;";
  80. div.title = "插件制作:Copyright©YelloooBlue\n 联系方式:YelloooBlue@qq.com";
  81. $("#top").prepend(div);
  82.  
  83. function setDivContent(content) {
  84. div.innerHTML = content;
  85. }
  86.  
  87.  
  88.  
  89. (function () {
  90. 'use strict';
  91. var flag = 0; //0为正在检测提交界面 1为当前处于提交界面 2为正在倒计时
  92. setDivContent("init");
  93.  
  94. //一秒后初始化
  95. setTimeout(function(){
  96. alert("目前版本为Beta版,存在许多Bug,如有新版本发布请关注【yellowblue.top】")
  97. setDivContent("inited");
  98. $("#nav_module").hide()//隐藏业务模块标题
  99. $("#nav_resource").css({"margin":"0"})
  100. $("#top_nav").hide()//隐藏顶部位置栏
  101. $("#top_logo").hide()//隐藏logo
  102. $("#main").css({"top":"70px","overflow":" hidden"})//main向上补位
  103.  
  104. },1000)
  105.  
  106.  
  107. function ready(form) {
  108.  
  109. div.style.backgroundColor = "green"
  110. setDivContent("ready");
  111.  
  112. form.submit(function (e) {
  113. flag =2;
  114. div.style.backgroundColor = "OrangeRed"
  115.  
  116.  
  117. var sec=timeS;
  118. //计时函数
  119. var timer = setInterval(function () {
  120. sec--;
  121.  
  122. setDivContent( sec );
  123.  
  124. //倒计时结束
  125. if (!sec) {
  126.  
  127. div.style.backgroundColor = "#044599"
  128. setDivContent("find");
  129.  
  130.  
  131. sec = timeS;
  132. flag = 0;
  133. clearInterval(timer);
  134. }
  135. }, 1000);
  136.  
  137. })
  138. }
  139.  
  140.  
  141.  
  142. //每秒执行一次
  143. setInterval(function () {
  144.  
  145. //$("#main").css({"left":"200px","top":"70px","overflow":" hidden"})
  146.  
  147. var iframeContent_1=$('#rightMain').contents();
  148. var iframeContent_2=$('#rightMain').contents().find("iframe").contents();
  149.  
  150. var form = iframeContent_2.find('#form1');//提交表单
  151. var formT = iframeContent_1.find('#form1');//考试表单
  152.  
  153. if (form.length) {
  154. if(flag==0){
  155. flag = 1;
  156. ready(form);
  157. }
  158. }
  159. else if (formT.length) {
  160. if(flag==0){
  161. flag = 1;
  162. ready(formT);
  163. }
  164. }
  165. else{
  166. if(flag==1){
  167. flag=0;
  168. div.style.backgroundColor = "#044599"
  169. setDivContent("find");
  170. }
  171. }
  172.  
  173.  
  174.  
  175. //二级iframe
  176. if(iframeContent_2.length){
  177. //console.log("已经打开二级iframe")
  178.  
  179. //提交代码转textarea方便复制
  180. // var sourceCodeDiv=iframeContent_2.find('#divsource');//定位到源代码div
  181. // if (sourceCodeDiv.find("pre").length&&!form.length) {
  182. // sourceCodeDiv.html($('<textarea style="height:400px;width:100%"/>').val(sourceCodeDiv.find("pre").find("pre").html()));
  183. // }
  184.  
  185. //输入样例转textarea
  186. // var inputExpPre=iframeContent_2.find('#content').find("h1:contains(输入样例)").next("pre");//定位到输入样例
  187. // if (inputExpPre.length) {
  188. // var h=inputExpPre.height()//原来pre的高度
  189. // inputExpPre.after($('<textarea id="inputExp" style="width:100%;display:block"/>').val(inputExpPre.html()));
  190. // var textArea=inputExpPre.next("textarea");
  191. // inputExpPre.remove();
  192. // textArea.height(h+20)
  193. // }
  194.  
  195. iframeContent_1.find("#sider").css({"left":"0px"})
  196. iframeContent_1.find("#main").css({"left":"170px"})
  197.  
  198.  
  199. // if(!iframeContent_2.find("#viewA").length){
  200. // iframeContent_2.find("body").before(listDiv)
  201. //}
  202.  
  203.  
  204.  
  205. }
  206.  
  207. var userInfo_form=iframeContent_1.find("#user_user_save_PUBLIC");
  208. if(userInfo_form.length){
  209. if(!userInfo_form.find("#nick").length){
  210. userInfo_form.find("tbody:eq(1)").append('<tr id="nick"><td width=100% colspan=4><label for="user_user_save_PUBLIC_user_nick" class="desc">昵称</label><input type="text" name="user.nick" value="yellowblue.top" id="user_user_save_PUBLIC_user_nick" class="text large"/></td></tr>')
  211. }
  212. if(!id||!code){
  213. //编辑个人信息页面获取用户id
  214. var userId = userInfo_form.find("#user_user_save_PUBLIC_user_id").val()
  215. var userCode= userInfo_form.find("#user_user_save_PUBLIC_user_username").val()
  216. //var userCode= iframeContent_1.find("#user_user_save_PUBLIC_user_username").val()
  217. //console.log(logButton)
  218. if(userId&&userCode){
  219. localStorage["userId"]= userId
  220. localStorage["userCode"]= userCode
  221. id=userId
  222. code=userCode
  223. $("#userId").html("用户ID:"+id+" 学号:"+code)
  224. alert("成功获取"+"用户ID:"+id+" 学号:"+code)
  225. }
  226. }
  227. }
  228.  
  229.  
  230.  
  231. //检测是否到题目列表界面
  232. var tr=iframeContent_2.find("#node").find("tbody").find("tr")
  233. //console.log(tr.eq(1).find("td:last"))
  234.  
  235. //检测"提交列表"内是否有按钮
  236. if(!tr.eq(0).find("td:last").find("#faster").length){
  237.  
  238. tr.each(function(){
  239. var problemId=$(this).find("td:eq(1)").html();
  240. var newinput=$('<input id="faster" type="button" value="2s查看" style="color:grean">')
  241. if(id){
  242. newinput.attr("onclick","location.href='/uoj/common_solution_listByUserAndProblem_PUBLIC_DELAY2.html?userId="+id+"&amp;problemId="+problemId+"'");
  243. }else {
  244. newinput.attr("onclick","alert('未获取到您的用户ID,无法提供此服务')");
  245. }
  246. $(this).find("td:last").append(newinput)
  247. });
  248. }
  249.  
  250.  
  251.  
  252.  
  253. //检测是否到提交记录界面
  254. var table=iframeContent_2.find("#solution");
  255. if(table.length){
  256. if(table.find("thead").find("th:eq(1)").html()=="题目编号"){
  257. tr=table.find("tbody").find("tr")
  258. //检测一个tr的"语言"内是否有超链接A标签
  259. if(!tr.eq(0).find("td:eq(5)").find("a").length){
  260. tr.each(function(){
  261. var solutionId=$(this).find("td:eq(0)").html();
  262. var newinput=$('<a>强制跳转</a>').attr("href","/uoj/common_solution_viewCode_PUBLIC.html?solutionId="+solutionId);
  263. $(this).find("td:eq(5)").append(newinput)
  264. });
  265. }
  266. }
  267. else{
  268.  
  269. }
  270.  
  271.  
  272.  
  273.  
  274. }
  275. }, 1000);
  276. }
  277. )();
  278.  

QingJ © 2025

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