云开作业自动答题

云开作业(只答客观题) https://yunao.open.com.cn 自动答题脚本;先用任意帐号登陆 https://learn.open.com.cn 平台才能自动答题。

  1. // ==UserScript==
  2. // @name 云开作业自动答题
  3. // @namespace https://gf.qytechs.cn/zh-CN/users/707063-genexy
  4. // @version 202311221507
  5. // @description 云开作业(只答客观题) https://yunao.open.com.cn 自动答题脚本;先用任意帐号登陆 https://learn.open.com.cn 平台才能自动答题。
  6. // @author 流浪的蛊惑
  7. // @connect learn.open.com.cn
  8. // @match *://*.open.com.cn/*
  9. // @grant GM_xmlhttpRequest
  10. // @run-at document-idle
  11. // @license MIT
  12. // ==/UserScript==
  13. function addXMLRequestCallback(callback){//监听请求
  14. var oldSend, i;
  15. if( XMLHttpRequest.callbacks ) {
  16. XMLHttpRequest.callbacks.push( callback );
  17. } else {
  18. XMLHttpRequest.callbacks = [callback];
  19. oldSend = XMLHttpRequest.prototype.send;
  20. XMLHttpRequest.prototype.send = function(){//监听发送
  21. for( i = 0; i < XMLHttpRequest.callbacks.length; i++ ) {
  22. XMLHttpRequest.callbacks[i]( this );
  23. }
  24. oldSend.apply(this, arguments);
  25. }
  26. XMLHttpRequest.prototype.wrappedSetRequestHeader=XMLHttpRequest.prototype.setRequestHeader;
  27. XMLHttpRequest.prototype.setRequestHeader = function(header, value) {//监听自定义主机头
  28. this.wrappedSetRequestHeader(header, value);
  29. if(!this.headers) {
  30. this.headers = {};
  31. }
  32. if(!this.headers[header]) {
  33. this.headers[header] = [];
  34. }
  35. this.headers[header].push(value);
  36. }
  37. }
  38. }
  39. function gGetData(url,item){
  40. GM_xmlhttpRequest({
  41. method: "get",
  42. url: url,
  43. onload: function(res){
  44. let data=JSON.parse(res.responseText);
  45. let choiceslist = data.data.Choices;
  46. let questionlist = new Array();
  47. let choicesIndex = [];
  48. choiceslist.forEach((iteam, index, array) =>{
  49. if (iteam.IsCorrect){
  50. for(let i=0;i<item.I6.length;i++){
  51. if(item.I6[i]==iteam.I2){
  52. choicesIndex.push(i);
  53. questionlist.push(iteam.I2);
  54. }
  55. }
  56. }
  57. });
  58. //直接定位当前试题
  59. let dom = document.querySelector("div[id='children" + item.I1 + "']");
  60. //点击答案
  61. let gr=dom.getElementsByClassName("el-radio-group")[0];
  62. if(gr==undefined){
  63. gr=dom.getElementsByClassName("el-checkbox-group")[0];
  64. }
  65. let st=0;
  66. choicesIndex.forEach((iteam, index, array) =>{
  67. if(gr.getElementsByTagName("input")[iteam].checked==false){
  68. setTimeout(()=>{gr.getElementsByTagName("input")[iteam].click();},st);
  69. st += 200 + Math.floor(Math.random() * 500);
  70. }
  71. });
  72. }
  73. });
  74. }
  75. //根据问题找出具体的id
  76. function initquestion(question){
  77. //遍历试题
  78. let list = question.Items;
  79. list.forEach((item, index, array)=>{
  80. //调用答案接口
  81. let basturl = "https://learn.open.com.cn/StudentCenter/OnlineJob/GetQuestionDetail?itemBankId=${itemBankId}&questionId=${questionId}";
  82. let itemBankId = item.I4;
  83. let questionId = item.I1;
  84. let rquurl = basturl.replace("${itemBankId}", itemBankId).replace("${questionId}", questionId);
  85. gGetData(rquurl,item);
  86. });
  87. }
  88. (function(){
  89. 'use strict';
  90. addXMLRequestCallback(function(xhr){
  91. xhr.addEventListener("load",function(){
  92. if (xhr.readyState == 4 && xhr.status == 200){
  93. console.log(xhr.responseURL);
  94. if (xhr.responseURL.includes("yunao.open.com.cn/api/student/student-space-service/testExam/goDoExamine")){
  95. let gdat=JSON.parse(xhr.responseText);
  96. initquestion(JSON.parse(gdat.content.answerResult.paperData));
  97. }
  98. }
  99. });
  100. });
  101. })();

QingJ © 2025

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