Icourse163_Auto_Full_Score_Review

在icourse163(中国大学MOOC)的作业自评互评中对每个题自动选择最大的分数并自动填写评语。投我以木桃,报之以琼瑶。人人为我,我为人人。

安装此脚本?
作者推荐脚本

您可能也喜欢EnablePIP-icourse163

安装此脚本
  1. // ==UserScript==
  2. // @name Icourse163_Auto_Full_Score_Review
  3. // @namespace Icourse163
  4. // @version 0.0.4
  5. // @description 在icourse163(中国大学MOOC)的作业自评互评中对每个题自动选择最大的分数并自动填写评语。投我以木桃,报之以琼瑶。人人为我,我为人人。
  6. // @author XenoAmess
  7. // @match https://www.icourse163.org/*
  8. // @run-at document-end
  9. // @grant none
  10. // @supportURL https://github.com/XenoAmess/icourse163_auto_full_score_review.git
  11. // ==/UserScript==
  12.  
  13. var REFRESH_TIME = 100;
  14. var REG = RegExp(/^http(s)?:\/\/www\.icourse163\.org\/.*\/learn\/hw.*/);
  15. /**
  16. * 自动填写的评语将从COMMENT_STRINGS_LIST中随机抽取。
  17. * 请确保COMMENT_STRINGS_LIST中没有空项。
  18. * 请确保COMMENT_STRINGS_LIST中每个项数字连续。
  19. * 请确保COMMENT_STRINGS_LIST中至少含有一个项。
  20. */
  21. var COMMENT_STRINGS_LIST = [];
  22. COMMENT_STRINGS_LIST[0] = "好的。";
  23.  
  24. function getRandomInt(max) {
  25. return Math.floor(Math.random() * Math.floor(max));
  26. }
  27.  
  28. function doIt() {
  29. if (window.location.href.match(REG) == null) {
  30. return;
  31. }
  32. return doItNonCheck();
  33. }
  34.  
  35. function parseFloatEx(string) {
  36. var res = "";
  37. for (var i = 0; i < string.length; i++) {
  38. var chr = string.charAt(i);
  39. if ((chr >= '0' && chr <= '9') || chr === '.') {
  40. res += chr;
  41. }
  42. }
  43. return parseFloat(res);
  44. }
  45.  
  46. function doItNonCheck() {
  47. var i, j, k;
  48.  
  49. if (!window.jQuery) {
  50. var oScript = document.createElement('script');
  51. oScript.type = "text/javascript";
  52. oScript.src = "//s1.hdslb.com/bfs/static/jinkela/long/js/jquery/jquery1.7.2.min.js";
  53. document.head.appendChild(oScript);
  54. }
  55. var scorePanelList = $("div.detail>div.s");
  56. for (i = 0; i < scorePanelList.length; i++) {
  57. var scorePanel = scorePanelList[i];
  58. var maxScore = -1;
  59. var maxIndex = -1;
  60. for (j = 0; j < scorePanel.children.length; j++) {
  61. for (k = 0; k < scorePanel.children[j].children.length; k++) {
  62. if (scorePanel.children[j].children[k].type === "radio") {
  63. // console.log(scorePanel.children[j].children[k].value);
  64. // console.log(parseFloatEx(scorePanel.children[j].children[k].value));
  65. var nowScore = parseFloatEx(scorePanel.children[j].children[k].value);
  66. var nowIndex = j;
  67. if (maxScore < nowScore) {
  68. maxScore = nowScore;
  69. maxIndex = nowIndex;
  70. }
  71. }
  72. }
  73. }
  74. console.log("maxIndex:" + maxIndex);
  75. console.log("maxScore:" + maxScore);
  76. if (maxIndex !== -1) {
  77. for (k = 0; k < scorePanel.children[maxIndex].children.length; k++) {
  78. if (scorePanel.children[maxIndex].children[k].type === "radio") {
  79. console.log($(scorePanel.children[maxIndex].children[k]));
  80. $(scorePanel.children[maxIndex].children[k]).attr('checked','true');
  81. }
  82. }
  83. }
  84. }
  85.  
  86. var commentTextAreaList = $("textarea.j-textarea.inputtxt");
  87. for (i = 0; i < commentTextAreaList.length; i++) {
  88. var commentTextArea = commentTextAreaList[i];
  89. if (commentTextArea.value === undefined || commentTextArea.value === null || commentTextArea.value === "" || commentTextArea.value.length === 0) {
  90. commentTextArea.value = COMMENT_STRINGS_LIST[getRandomInt(COMMENT_STRINGS_LIST.length)];
  91. }
  92. }
  93. }
  94.  
  95. (function () {
  96. 'use strict';
  97. window.onload = window.setInterval(doIt, REFRESH_TIME);
  98. })();

QingJ © 2025

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