One_Key_MOOC_HOMEWORK

f*ck mooc homework and AutoRate Course

  1. // ==UserScript==
  2. // @name One_Key_MOOC_HOMEWORK
  3. // @version 1.0.04
  4. // @match *://www.icourse163.org/learn/*
  5. // @match *://www.icourse163.org/spoc/learn/*
  6. // @author caigoul & Caiji-bai
  7. // @grant MIT
  8. // @description f*ck mooc homework and AutoRate Course
  9. // @namespace https://gf.qytechs.cn/users/301293
  10. // ==/UserScript==
  11.  
  12. console.log(
  13. `
  14.  
  15. ██████ ██░ ██ ▒█████ █░ ███▄ ▄███▓▓█████
  16. ▒██ ▓██░ ██▒▒██▒ ██▒▓█░ ░█░▓██▒▀█▀ ██▒▓█
  17. ▓██▄ ▒██▀▀██░▒██░ ██▒▒█░ ░█ ▓██ ▓██░▒███
  18. ██▒░▓█ ░██ ▒██ ██░░█░ ░█ ▒██ ▒██ ▒▓█
  19. ▒██████▒▒░▓█▒░██▓░ ████▓▒░░░██▒██▓ ▒██▒ ░██▒░▒████▒
  20. ▒▓▒ ░░▒░▒░ ▒░▒░▒░ ▓░▒ ▒░ ░░░ ▒░
  21. ░▒ ░▒░ ▒░
  22. ░░ ░░
  23.  
  24. ▄▄▄█████▓ ██░ ██ ▓█████ ▄▄▄ ███▄ ██████ █░▓█████ ██▀███
  25. ██▒ ▓▒▓██░ ██▒▓█ ▀▒████▄ ██ ▀█ ▒██ ▓█░ ░█░▓█ ▓██ ██▒
  26. ▓██░ ▒░▒██▀▀██░▒███ ▒██ ▀█▄ ▓██ ▀█ ██▒░ ▓██▄ ▒█░ ░█ ▒███ ▓██ ░▄█
  27. ▓██▓ ░▓█ ░██ ▒▓█ ▄░██▄▄▄▄██ ▓██▒ ▐▌██▒ ██▒░█░ ░█ ▒▓█ ▒██▀▀█▄
  28. ▒██▒ ░▓█▒░██▓░▒████▒▓█ ▓██▒▒██░ ▓██░▒██████▒▒░░██▒██▓ ░▒████▒░██▓ ▒██▒
  29. ░░ ░░▒░▒░░ ▒░ ░▒▒ ▓▒█░░ ▒░ ▒▓▒ ░░ ▓░▒ ░░ ▒░ ░░ ▒▓ ░▒▓░
  30. ░▒░ ▒▒ ░░ ░░ ▒░░ ░▒ ░▒ ▒░
  31. ░░ ░░
  32.  
  33.  
  34. ┌─┐ ┌─┐┬┌┬┐┌─┐┬ ┌─┐ ╦┌─┐┬ ┬┌─┐┌─┐┌─┐┬─┐┬┌─┐┌┬┐ ┌┬┐┌─┐┌┬┐┌─┐
  35. ├─┤ └─┐││││├─┘│ ├┤ ║├─┤└┐┌┘├─┤└─┐│ ├┬┘│├─┘ ││├┤ ││││
  36. └─┘┴┴ ┴┴ ┴─┘└─┘ ╚╝┴ └┘ ┴└─┘└─┘┴└─┴┴ ─┴┘└─┘┴ ┴└─┘
  37. _________________________________________________________________
  38. author: caigoul & Caiji-bai
  39. HAVE FUN!
  40. `
  41. );
  42.  
  43. (function() {
  44. function F_ck_One_HomeWork() {
  45. var s = document.getElementsByClassName("s");
  46. for (var i = 0; i < s.length; i++) {
  47. let choice = s[i].children[s[i].children.length - 1].control;
  48. choice.checked = true;
  49. }
  50.  
  51. var cs = document.getElementsByClassName("j-textarea inputtxt");
  52. for (let i = 1; i < cs.length; i++) cs[i].value = "Good Job";
  53.  
  54. // window.setTimeout(() => {
  55. document
  56. .getElementsByClassName("u-btn u-btn-default f-fl j-submitbtn")[0]
  57. .click();
  58. // window.setTimeout(() => {
  59. document.getElementsByClassName("j-gotonext")[0].click();
  60. // }, 1024);
  61. // }, 1024);
  62. }
  63.  
  64. // 批改作业.jpg
  65. if (window.location.hash.indexOf("#/learn/hw?id=") != -1) {
  66. var button = document.createElement("button");
  67. button.innerHTML = "F*CK ONE HOMEWORK";
  68. button.className = "u-btn u-btn-default f-fl";
  69. button.style.position = "fixed";
  70. button.style.top = "200px";
  71. button.style.left = "0px";
  72. button.style.zIndex = "50";
  73. var body = document.getElementsByTagName("body")[0];
  74. body.appendChild(button);
  75. button.onclick = function() {
  76. let count = 6;
  77. get_aid();
  78. var start = window.setInterval(() => {
  79. F_ck_One_HomeWork();
  80. count--;
  81. if (count == 0) window.clearInterval(start);
  82. }, 2000);
  83. };
  84. }
  85.  
  86. // show_me_the_answer
  87. body = document.getElementsByTagName("body")[0];
  88. var button2 = document.createElement("button");
  89. button2.innerHTML = "SHOW_ME_THE_ANSWER";
  90. button2.className = "u-btn u-btn-default f-fl";
  91. button2.style.position = "fixed";
  92. button2.style.top = "250px";
  93. button2.style.left = "0px";
  94. button2.style.zIndex = "50";
  95. body.appendChild(button2);
  96. button2.onclick = function() {
  97. parse_answer(answers => {
  98. create_Window(answers);
  99. if (location.hash.indexOf("learn/hw?id=") != -1) {
  100. show_answer_in_homework(answers);
  101. }
  102. if (location.hash.indexOf("learn/quiz?id=") != -1) {
  103. show_answer_in_quiz(answers);
  104. }
  105. if (location.hash.indexOf("learn/examObject?eid=") != -1) {
  106. show_answer_in_quiz(answers);
  107. }
  108. if (location.hash.indexOf("learn/examSubjective?eid=") != -1) {
  109. show_answer_in_homework(answers);
  110. }
  111. });
  112. };
  113.  
  114. var get_aid = function(callback = alert) {
  115. var id;
  116. var method;
  117. var isEid = false;
  118. if ((id = window.location.href.match(/hw\?id=(.*)/))) {
  119. id = id[1];
  120. method = "getHomeworkInfo";
  121. } else if ((id = window.location.href.match(/quiz\?id=(.*)/))) {
  122. id = id[1];
  123. method = "getQuizInfo";
  124. } else if ((id = window.location.href.match(/eid=(.*)\&id=(.*)/))) {
  125. id = id[2];
  126. method = "getQuizInfo";
  127. isEid = true;
  128. }
  129. let msg = `callCount=1
  130. scriptSessionId=\$\{scriptSessionId\}190
  131. c0-scriptName=MocQuizBean
  132. c0-methodName=${method}
  133. c0-id=0
  134. c0-param0=string:${id}
  135. c0-param1=null:null
  136. c0-param2=boolean:false
  137. batchId=1553856368973`;
  138. let request = new XMLHttpRequest();
  139. request.open(
  140. "POST",
  141. "https://www.icourse163.org/dwr/call/plaincall/MocQuizBean.getHomeworkInfo.dwr"
  142. );
  143. request.setRequestHeader("Content-Type", "text/plain");
  144. request.onreadystatechange = function() {
  145. if (request.readyState === 4) {
  146. let aid = request.responseText.match(/aid:(.*?),/);
  147. if (!aid) {
  148. method = method == "getQuizInfo" ? "getHomeworkInfo" : "getQuizInfo";
  149. msg = `callCount=1
  150. scriptSessionId=\$\{scriptSessionId\}190
  151. c0-scriptName=MocQuizBean
  152. c0-methodName=${method}
  153. c0-id=0
  154. c0-param0=string:${id}
  155. c0-param1=null:null
  156. c0-param2=boolean:false
  157. batchId=1553856368973`;
  158. request.open(
  159. "POST",
  160. "https://www.icourse163.org/dwr/call/plaincall/MocQuizBean.getHomeworkInfo.dwr"
  161. );
  162. request.send(msg);
  163. } else {
  164. callback(aid[1], id, isEid);
  165. }
  166. }
  167. };
  168. request.send(msg);
  169. };
  170.  
  171. var get_answer = function(callback = alert) {
  172. get_aid((aid, id, isEid) => {
  173. let url = isEid
  174. ? "https://www.icourse163.org/dwr/call/plaincall/MocQuizBean.getQuizPaperDto.dwr"
  175. : "https://www.icourse163.org/dwr/call/plaincall/MocQuizBean.getHomeworkPaperDto.dwr";
  176. let msg = `callCount=1
  177. scriptSessionId=\$\{scriptSessionId\}190
  178. c0-scriptName=MocQuizBean
  179. c0-methodName=getHomeworkPaperDto
  180. c0-id=0
  181. c0-param0=number:${id}
  182. c0-param1=number:${aid}
  183. c0-param2=boolean:true
  184. c0-param3=number:
  185. c0-param4=number:
  186. batchId=${aid}`;
  187. let request = new XMLHttpRequest();
  188. request.open("POST", url);
  189. request.setRequestHeader("Content-Type", "text/plain");
  190. request.onreadystatechange = function() {
  191. if (request.readyState === 4) {
  192. callback(request.responseText);
  193. }
  194. };
  195. request.send(msg);
  196. });
  197. };
  198.  
  199. var parse_answer = function(callback) {
  200. get_answer(function(answer) {
  201. let answers = answer
  202. .match(
  203. /(?:title="(.*?)";)|(?:answer=(true|false);s.*?content="(.*?)";)|(?:maxScore=.*?;s.*?msg="(.*?)";)|(?:stdAnswer="(.*?)";)/gm
  204. )
  205. .join("\n");
  206. while (answers.indexOf('\\"') !== -1)
  207. answers = answers.replace('\\"', "");
  208. answers = unescape(answers.replace(/\\u/g, "%u"));
  209. callback(answers);
  210. });
  211. };
  212.  
  213. var show_answer_in_homework = function(answers) {
  214. var answersarr = [];
  215. var titles = [];
  216. answers.split('title="').forEach(item => {
  217. const msg = item.split(/maxScore=\d*;s\d*.msg="/);
  218. // console.log(msg);
  219. titles.push(msg.shift());
  220. answersarr.push(msg);
  221. });
  222. titles.shift();
  223. answersarr.shift();
  224. var questions = document.getElementsByClassName(
  225. "f-richEditorText j-richTxt f-fl"
  226. );
  227. for (let i = 0; i < questions.length; i++) {
  228. var answer = answersarr[i].join();
  229. answer = answer.replace(/";/g, "");
  230. questions[i].innerHTML = titles[i].replace(/";/g, "");
  231. questions[i].innerHTML += "<hr>";
  232. questions[i].innerHTML +=
  233. "<h1 style=\"color:red;font-family:'楷体'\">答案:</h1>";
  234. questions[i].innerHTML += answer;
  235. questions[i].innerHTML += "<hr>";
  236. }
  237. };
  238.  
  239. var show_answer_in_quiz = function(answers) {
  240. var tmp = answers.split('title="');
  241. var answersarr = [];
  242. var questions = document.getElementsByClassName(
  243. "f-richEditorText j-richTxt"
  244. );
  245. tmp.shift();
  246. for (let i = 0; i < tmp.length; i++) {
  247. var match_answers = tmp[i].match(/answer=true;s\d+\.content="(.*?)"/g);
  248. if (match_answers) {
  249. answersarr[i] = ''
  250. match_answers.forEach(item => {
  251. var answer = item.match(/answer=true;s\d+\.content="(.*?)"/)
  252. answersarr[i] += answer[1];
  253. })
  254. }
  255. match_answers = tmp[i].match(/stdAnswer="(.*?)"/);
  256. if (match_answers) {
  257. answersarr[i + 1] = match_answers[1].replace(/##%_YZPRLFH_%##/g, '或');
  258. }
  259. }
  260. for (let i = 0; i < questions.length; i++) {
  261. questions[i].innerHTML += "<hr>";
  262. questions[i].innerHTML +=
  263. "<h1 style=\"color:red;font-family:'楷体'\">答案:</h1>";
  264. questions[i].innerHTML += answersarr[i];
  265. questions[i].innerHTML += "<hr>";
  266. }
  267. };
  268.  
  269. // 显示答案.jpg
  270. var create_Window = function(answers) {
  271. var id = document.getElementById("windows");
  272. if (id) {
  273. return;
  274. }
  275. var win = document.createElement("div");
  276. var button3 = document.createElement("button");
  277. win.setAttribute("id", "windows");
  278. win.style.background = "#fff";
  279. win.style.width = "max-content";
  280. win.style.maxWidth = "800px";
  281. win.style.height = "700px";
  282. win.style.position = "fixed";
  283. win.style.right = "30px";
  284. win.style.top = "200px";
  285. win.style.boxShadow = "0px 0px 10px #848484";
  286. win.style.padding = "40px 40px";
  287. win.style.overflow = "auto";
  288. win.style.zIndex = "100";
  289. win.innerHTML = answers;
  290. document.getElementsByTagName("body")[0].appendChild(win);
  291. win.appendChild(button3);
  292. button3.innerHTML = "close ";
  293. button3.className = "u-btn u-btn-default f-fl";
  294. button3.style.position = "fixed";
  295. button3.style.top = "300px";
  296. button3.style.left = "0px";
  297. button3.style.zIndex = "50";
  298. button3.onclick = function() {
  299. body.removeChild(win);
  300. };
  301. _drag(win);
  302. };
  303.  
  304. var _drag = function(el) {
  305. var x = 0;
  306. var y = 0;
  307. var l = 0;
  308. var t = 0;
  309. var isDown = false;
  310. //鼠标按下事件
  311. el.onmousedown = function(e) {
  312. //获取x坐标和y坐标
  313. x = e.clientX;
  314. y = e.clientY;
  315.  
  316. //获取左部和顶部的偏移量
  317. l = el.offsetLeft;
  318. t = el.offsetTop;
  319. //开关打开
  320. isDown = true;
  321. //设置样式
  322. el.style.cursor = "move";
  323. };
  324. //鼠标移动
  325. window.onmousemove = function(e) {
  326. if (isDown == false) {
  327. return;
  328. }
  329. //获取x和y
  330. var nx = e.clientX;
  331. var ny = e.clientY;
  332. //计算移动后的左偏移量和顶部的偏移量
  333. var nl = nx - (x - l);
  334. var nt = ny - (y - t);
  335.  
  336. el.style.left = nl + "px";
  337. el.style.top = nt + "px";
  338. };
  339. //鼠标抬起事件
  340. el.onmouseup = function() {
  341. //开关关闭
  342. isDown = false;
  343. el.style.cursor = "default";
  344. };
  345. };
  346. })();

QingJ © 2025

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