武汉大学教务系统自动评教-Teaching Evaluation For WHU

自动评教,点击开始按钮即可执行评教操作。

  1. // ==UserScript==
  2. // @name 武汉大学教务系统自动评教-Teaching Evaluation For WHU
  3. // @namespace plusv
  4. // @version 1.1
  5. // @description 自动评教,点击开始按钮即可执行评教操作。
  6. // @match https://ugsqs.whu.edu.cn/new/student/rank/*
  7. // @grant none
  8. // @license MIT
  9. // ==/UserScript==
  10.  
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. // 创建开始按钮
  16. const startBtn = document.createElement('button');
  17. startBtn.textContent = '任意键评教';
  18. startBtn.style.position = 'fixed';
  19. startBtn.style.zIndex = 114514;
  20. startBtn.style.top = '50%';
  21. startBtn.style.left = '50%';
  22. startBtn.style.transform = 'translate(-50%, -50%)';
  23. startBtn.style.backgroundColor = '#01aba0';
  24. startBtn.style.border = 'none';
  25. startBtn.style.borderRadius = '4px';
  26. startBtn.style.color = '#fff';
  27. startBtn.style.fontSize = '16px';
  28. startBtn.style.fontWeight = 'bold';
  29. startBtn.style.padding = '12px 24px';
  30. startBtn.style.cursor = 'pointer';
  31. startBtn.style.transition = 'all 0.3s ease';
  32. startBtn.style.boxShadow = '0px 2px 6px rgba(0, 0, 0, 0.3)'; // 添加阴影效果
  33. // 添加圆角
  34. startBtn.style.webkitBorderRadius = '10px';
  35. startBtn.style.mozBorderRadius = '10px';
  36. startBtn.style.borderRadius = '10px';
  37. document.body.appendChild(startBtn);
  38.  
  39. // 点击开始按钮执行评教操作
  40. startBtn.addEventListener('click', async function() {
  41. // 获取所有单选题的元素
  42. const questions = document.querySelectorAll('.dxt');
  43.  
  44. // 遍历每个单选题
  45. questions.forEach(question => {
  46. // 获取该题的所有选项元素
  47. const options = question.querySelectorAll('input[type="radio"]')
  48.  
  49. // 找到最大的选项值
  50. let maxOption = options[0];
  51. for (let i = 1; i < options.length; i++) {
  52. if (parseFloat(options[i].value) > parseFloat(maxOption.value)) {
  53. maxOption = options[i];
  54. }
  55. }
  56.  
  57. // 点击最大的选项
  58. maxOption.click();
  59. });
  60.  
  61. // 获取第一个单选题元素
  62. const question = document.querySelector('.dxt');
  63.  
  64. // 获取该题的所有选项元素
  65. const options = question.querySelectorAll('input[type="radio"]');
  66.  
  67. // 点击第二个选项
  68. options[1].click();
  69.  
  70. // 获取文本框元素
  71. const input = document.querySelector('textarea[name="2259"]');
  72.  
  73. // 设置文本框的值为"无"
  74. input.value = "无";
  75.  
  76. // 创建一个名为"input"的事件
  77. const event = new Event('input', { bubbles: true });
  78.  
  79. // 触发文本框的"input"事件
  80. input.dispatchEvent(event);
  81.  
  82. // 获取提交按钮元素
  83. const submitBtn = document.getElementById('pjsubmit');
  84.  
  85. // 点击提交按钮
  86. submitBtn.click();
  87.  
  88. // 等待1秒钟
  89. await new Promise(resolve => setTimeout(resolve, 100));
  90.  
  91. // 在这里执行等待1秒后需要执行的代码
  92. // 获取关闭按钮元素
  93. const closeBtn = document.querySelector('#finishDlg button[data-dismiss="modal"]');
  94.  
  95. // 点击关闭按钮
  96. closeBtn.click();
  97. });
  98.  
  99. // 使用 MutationObserver 监听页面变化
  100. const observer = new MutationObserver(mutations => {
  101. mutations.forEach(mutation => {
  102. // 如果新增节点是在 body 下,且不是 startBtn 按钮,则重新设置 startBtn 的 z-index 属性
  103. if (mutation.addedNodes.length && mutation.addedNodes[0].parentNode === document.body && mutation.addedNodes[0] !== startBtn) {
  104. startBtn.style.zIndex = 114514; // 最高图层的 z-index 值
  105. }
  106. });
  107. });
  108.  
  109. // 监听键盘按下事件
  110. window.addEventListener('keydown', function handleKeyDown(event) {
  111. // 确保用户按下的是任意键,而不是特殊键,如 shift、ctrl、alt 等
  112. if (event.keyCode !== 16 && event.keyCode !== 17 && event.keyCode !== 18) {
  113. // 触发开始按钮的点击事件
  114. startBtn.click();
  115. }
  116. });
  117.  
  118.  
  119. // 开始监听页面变化
  120. observer.observe(document.body, { childList: true });
  121. })();

QingJ © 2025

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