up_tk

up_tk_1.0

当前为 2025-02-09 提交的版本,查看 最新版本

此脚本不应直接安装。它是供其他脚本使用的外部库,要使用该库请加入元指令 // @require https://update.cn-greasyfork.org/scripts/526341/1534141/up_tk.js

  1. function upLoadWork(index, doms, dom) {
  2. let $CyHtml = $(dom).contents().find(".CeYan");
  3. let TiMuList = $CyHtml.find(".TiMu");
  4. let data = [];
  5. for (let i = 0; i < TiMuList.length; i++) {
  6. let _a = {};
  7. let questionFull = $(TiMuList[i]).find(".Zy_TItle.clearfix > div.clearfix").html().trim();
  8. let _question = tidyQuestion(questionFull);
  9. let _TimuType = { 单选题: 0, 多选题: 1, 填空题: 2, 判断题: 3, 简答题: 4 }[questionFull.match(/^<span.*?newZy_TItle.*?【(.*?)】<\/span>|$/)[1]];
  10. _a["question"] = _question;
  11. _a["type"] = _TimuType;
  12. let _selfAnswerCheck = $(TiMuList[i]).find(".newAnswerBx > .myAnswerBx > .answerScore .CorrectOrNot span").attr("class");
  13. switch (_TimuType) {
  14. case 0:
  15. if (_selfAnswerCheck == "marking_dui") {
  16. let _selfAnswer = { A: 0, B: 1, C: 2, D: 3, E: 4, F: 5, G: 6 }[$(TiMuList[i]).find(".newAnswerBx > .myAnswerBx > .myAnswer").text().trim().replace(/正确答案[::]/, "").replace(/我的答案[::]/, "").trim()];
  17. let _answerForm2 = $(TiMuList[i]).find(".Zy_ulTop li");
  18. let _answer2 = $(_answerForm2[_selfAnswer]).find("a.fl").html();
  19. _a["answer"] = tidyStr(_answer2);
  20. }
  21. break;
  22. case 1:
  23. let _answerArr = $(TiMuList[i]).find(".newAnswerBx > .myAnswerBx > .myAnswer").text().trim().replace(/正确答案[::]/, "").replace(/我的答案[::]/, "").trim();
  24. let _answerForm = $(TiMuList[i]).find(".Zy_ulTop li");
  25. let _answer = [];
  26. if (_selfAnswerCheck == "marking_dui" || _selfAnswerCheck == "marking_bandui") {
  27. for (let i2 = 0; i2 < _answerArr.length; i2++) {
  28. let _answerIndex = { A: 0, B: 1, C: 2, D: 3, E: 4, F: 5, G: 6 }[_answerArr[i2]];
  29. _answer.push($(_answerForm[_answerIndex]).find("a.fl").html());
  30. }
  31. } else {
  32. break;
  33. }
  34. _a["answer"] = tidyStr(_answer.join("#"));
  35. break;
  36. case 2:
  37. let _TAnswerArr = $(TiMuList[i]).find(".newAnswerBx > .myAnswerBx > .myAnswer");
  38. let _TAnswer = [];
  39. for (let i2 = 0; i2 < _TAnswerArr.length; i2++) {
  40. let item = _TAnswerArr[i2];
  41. if ($(item).find("i").attr("class") == "marking_dui") {
  42. _TAnswer.push($(item).find("p").html().replace(/[(][0-9].*?[)]/, "").replace(/第.*?空:/, "").trim());
  43. }
  44. }
  45. if (_TAnswer.length <= 0) {
  46. break;
  47. }
  48. _a["answer"] = tidyStr(_TAnswer.join("#"));
  49. break;
  50. case 3:
  51. if (_selfAnswerCheck == "marking_dui") {
  52. let _answer2 = $(TiMuList[i]).find(".newAnswerBx > .myAnswerBx > .myAnswer").html().replace(/正确答案[::]/, "").replace(/我的答案[::]/, "").trim();
  53. _a["answer"] = tidyStr(_answer2);
  54. } else {
  55. if ($(TiMuList[i]).find(".newAnswerBx > .myAnswerBx > .myAnswer").html()) {
  56. let _answer2 = $(TiMuList[i]).find(".newAnswerBx > .myAnswerBx > .myAnswer").html().replace(/正确答案[::]/, "").replace(/我的答案[::]/, "").trim();
  57. if ("对|√|正确".indexOf(tidyStr(_answer2)) != -1) {
  58. _a["answer"] = "错";
  59. } else {
  60. _a["answer"] = "对";
  61. }
  62. } else {
  63. break;
  64. }
  65. }
  66. break;
  67. }
  68. if (_a["answer"] != void 0) {
  69. data.push(_a);
  70. } else {
  71. continue;
  72. }
  73. }
  74. uploadAnswer(data, 0).then(() => {
  75. _mlist.splice(0, 1);
  76. _domList.splice(0, 1);
  77. setTimeout(() => {
  78. startDoCyWork(index + 1, doms);
  79. }, 3e3);
  80. });
  81. }
  82.  
  83. function uploadExam() {
  84. logger("考试答案收录功能处于bate阶段,遇到bug请及时反馈!!", "red");
  85. logger("开始收录考试答案", "green");
  86. let TimuList = $(".mark_table .mark_item .questionLi");
  87. let data = [];
  88. $.each(TimuList, (i, t) => {
  89. let _a = {};
  90. let _answer;
  91. let _answerTmpArr, _answerList = [];
  92. let TiMuFull = tidyQuestion($(t).find("h3").html());
  93. let _type = { 单选题: 0, 多选题: 1, 填空题: 2, 判断题: 3, 简答题: 4 }[TiMuFull.match(/[(](.*?)[)]|$/)[1].replace(/,.*?分/, "")];
  94. let _question = TiMuFull.replace(/^[(].*?[)]|$/, "").trim();
  95. let _rightAns = $(t).find(".mark_answer").find(".colorGreen").text().replace(/正确答案[::]/, "").trim();
  96. switch (_type) {
  97. case 0:
  98. if (_rightAns.length <= 0) {
  99. let _isTrue2 = $(t).find(".mark_answer").find(".mark_score span").attr("class");
  100. let _isZero = $(t).find(".mark_answer").find(".mark_score .totalScore.fr i").text();
  101. if (_isTrue2 == "marking_dui" || _isZero != "0") {
  102. _rightAns = $(t).find(".mark_answer").find(".colorDeep").text().replace(/我的答案[::]/, "").trim();
  103. } else {
  104. break;
  105. }
  106. }
  107. _answerTmpArr = $(t).find(".mark_letter li");
  108. $.each(_answerTmpArr, (a, b) => {
  109. _answerList.push(tidyStr($(b).html()).replace(/[A-Z].\s*/, ""));
  110. });
  111. let _i = { A: 0, B: 1, C: 2, D: 3, E: 4, F: 5, G: 6 }[_rightAns];
  112. _answer = _answerList[_i];
  113. _a["question"] = _question;
  114. _a["type"] = _type;
  115. _a["answer"] = _answer;
  116. data.push(_a);
  117. break;
  118. case 1:
  119. _answer = [];
  120. if (_rightAns.length <= 0) {
  121. let _isTrue2 = $(t).find(".mark_answer").find(".mark_score span").attr("class");
  122. let _isZero = $(t).find(".mark_answer").find(".mark_score .totalScore.fr i").text();
  123. if (_isTrue2 == "marking_dui" || _isTrue2 == "marking_bandui" || _isZero != "0") {
  124. _rightAns = $(t).find(".mark_answer").find(".colorDeep").text().replace(/我的答案[::]/, "").trim();
  125. } else {
  126. break;
  127. }
  128. }
  129. _answerTmpArr = $(t).find(".mark_letter li");
  130. $.each(_answerTmpArr, (a, b) => {
  131. _answerList.push(tidyStr($(b).html()).replace(/[A-Z].\s*/, ""));
  132. });
  133. $.each(_rightAns.split(""), (c, d) => {
  134. let _i2 = { A: 0, B: 1, C: 2, D: 3, E: 4, F: 5, G: 6 }[d];
  135. _answer.push(_answerList[_i2]);
  136. });
  137. _a["question"] = _question;
  138. _a["type"] = _type;
  139. _a["answer"] = _answer.join("#");
  140. data.push(_a);
  141. break;
  142. case 2:
  143. _answerTmpArr = [];
  144. let answers = $(t).find(".mark_answer").find(".colorDeep").find("dd");
  145. if (_rightAns.length <= 0) {
  146. $.each(answers, (i2, t2) => {
  147. _isTrue = $(t2).find("span:eq(1)").attr("class");
  148. if (_isTrue == "marking_dui") {
  149. _rightAns = $(t2).find("span:eq(0)").html();
  150. _answerTmpArr.push(_rightAns.replace(/[(][0-9].*?[)]/, "").replace(/第.*?空:/, "").trim());
  151. } else {
  152. return;
  153. }
  154. });
  155. _answer = _answerTmpArr.join("#");
  156. } else {
  157. _answer = _rightAns.replace(/\s/g, "").replace(/[(][0-9].*?[)]/g, "#").replace(/第.*?空:/g, "#").replace(/^#*/, "");
  158. }
  159. if (_answer.length != 0) {
  160. _a["question"] = _question;
  161. _a["type"] = _type;
  162. _a["answer"] = _answer;
  163. data.push(_a);
  164. }
  165. break;
  166. case 3:
  167. if (_rightAns.length <= 0) {
  168. let _isTrue2 = $(t).find(".mark_answer").find(".mark_score span").attr("class");
  169. let _isZero = $(t).find(".mark_answer").find(".mark_score .totalScore.fr i").text();
  170. if (_isTrue2 == "marking_dui" || _isZero != "0") {
  171. _rightAns = $(t).find(".mark_answer").find(".colorDeep").text().replace(/我的答案[::]/, "").trim();
  172. } else {
  173. let _true = "正确|是|对|√|T|ri";
  174. _rightAns = $(t).find(".mark_answer").find(".colorDeep").text().replace(/我的答案[::]/, "").trim();
  175. if (_true.indexOf(_rightAns) != -1) {
  176. _rightAns = "错";
  177. } else {
  178. _rightAns = "对";
  179. }
  180. }
  181. }
  182. _a["question"] = _question;
  183. _a["type"] = _type;
  184. _a["answer"] = _rightAns;
  185. data.push(_a);
  186. break;
  187. case 4:
  188. if (_rightAns.length <= 0) {
  189. break;
  190. }
  191. _a["question"] = _question;
  192. _a["type"] = _type;
  193. _a["answer"] = _rightAns;
  194. data.push(_a);
  195. break;
  196. }
  197. });
  198. setTimeout(() => {
  199. uploadAnswer(data, 0);
  200. }, 1500);
  201. }