NEU evaluatevl

neu 评教助手

  1. // ==UserScript==
  2. // @name NEU evaluatevl
  3. // @namespace http://tampermonkey.net/
  4. // @version 2024-11-30
  5. // @description neu 评教助手
  6. // @author yukaChen
  7. // @match http://210.30.204.138/school/proj/evaluatevl-0/module/task/org/*/mytask*
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=204.138
  9. // @grant none
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13. (function () {
  14. "use strict";
  15.  
  16. const currentUrl = window.location.href;
  17. let urlArr = currentUrl.split("/");
  18.  
  19. function delay(milliseconds) {
  20. return new Promise((resolve) => {
  21. setTimeout(resolve, milliseconds);
  22. });
  23. }
  24. async function evaluate() {
  25. console.log("start evaluating....");
  26. let tableRows = document.querySelectorAll("tr"); // btw I don't know why someone still use <table> tag today XD
  27. let saveResultBtn = document.querySelector("#btn-saveResult"); // the The second to last to submit
  28.  
  29. function checkAllRadio(tableRows) {
  30. tableRows.forEach((item) => {
  31. const itemChildren = item.children;
  32. // console.log(itemChildren.length);
  33. if (itemChildren.length > 5) {
  34. Array.from(itemChildren).forEach((child, index) => {
  35. // what index equals to will be varied based on many things.......
  36. // basically, it matched the scores you give your teacher
  37. if (index === 4) {
  38. const inputButton = child.querySelector("input[type='radio']");
  39. // console.log(child);
  40. if (inputButton) {
  41. // console.log(inputButton);
  42. inputButton.click();
  43. }
  44. }
  45. });
  46. }
  47. });
  48. }
  49. async function submitResult(saveResultBtn) {
  50. saveResultBtn.click();
  51. await delay(1 * 500);
  52. let confirmBtn = document.querySelector("button.confirm"); // confirm button, it's not on the dom
  53. confirmBtn.click();
  54. }
  55.  
  56. function next() {
  57. let returnBtn = document.querySelector("#btn-goBack");
  58. returnBtn.click();
  59. }
  60. checkAllRadio(tableRows);
  61. await delay(1 * 1000);
  62. submitResult(saveResultBtn);
  63. await delay(1 * 1000);
  64. next();
  65. }
  66.  
  67. function startNextEvaluate() {
  68. console.log("start next evaluating....");
  69. let startButton = document.querySelector("a.btn-primary");
  70. if (startButton) {
  71. startButton.click();
  72. }
  73. }
  74.  
  75. function main() {
  76. // usually, there is a detail path (/detail/...) in evaluate page
  77. if (urlArr.find((item) => item === "detail")) {
  78. setTimeout(evaluate, 1 * 1000);
  79. } else {
  80. setTimeout(startNextEvaluate, 1 * 1000);
  81. }
  82. }
  83. setTimeout(main, 2 * 1000);
  84. })();