温州大学SPOC自动答题

自动选择 SPOC 单选题的答案 只可以是单选题!! 因为没有做到多选题

目前為 2025-04-18 提交的版本,檢視 最新版本

// ==UserScript==
// @name         温州大学SPOC自动答题
// @namespace    hahahahaha
// @license MIT
// @version      1.02
// @description  自动选择 SPOC 单选题的答案 只可以是单选题!! 因为没有做到多选题
// @author       col
// @match        *://*/*
// @grant        none
// @run-at       document-start
// ==/UserScript==

(function () {
  'use strict';

  // 1. 拦截 jQuery.ajax 请求
  const _ajax = window.jQuery && window.jQuery.ajax;
  if (_ajax) {
    window.jQuery.ajax = function (opts) {
      const origSuccess = opts.success;
      opts.success = function (data, ...args) {
        try {
          if (opts.url.includes("getExamPaper")) {
            localStorage.setItem("spoc_examData", JSON.stringify(data));
            console.log("[自动答题] 成功拦截考试数据并保存!");
          }
        } catch (e) {
          console.error("拦截失败:", e);
        }
        if (typeof origSuccess === "function") {
          return origSuccess.call(this, data, ...args);
        }
      };
      return _ajax.call(this, opts);
    };
  }

  // 2. 快捷键 Alt+A 显示作答情况
  window.addEventListener("keydown", function (e) {
    if (e.altKey && e.key === "a") {
      const raw = localStorage.getItem("spoc_examData");
      if (!raw) {
        alert("未获取到考试数据,请先进入试卷页面!");
        return;
      }

      try {
        const examData = JSON.parse(raw);
        const rawArray = JSON.parse(examData.examSubmit.submitContent);
        const submitContent = rawArray.map(item => JSON.parse(item));

        let result = "📘 题目答题情况如下(Alt+A 唤出)\n\n";
        submitContent.forEach((item, index) => {
          const markQuizScore = parseInt(item.markQuizScore);
          const isCorrect = markQuizScore !== 0;
          const questionNumber = index + 1;
          result += `题目 ${questionNumber}:${isCorrect ? '✅ 正确' : '❌ 错误'}\n`;
        });

        alert(result);
      } catch (err) {
        console.error("处理答题数据出错:", err);
        alert("处理答题数据时出错,请检查控制台");
      }
    }
  });

  console.log("[自动答题] 油猴脚本已加载,按 Alt+A 查看答题结果");
})();

QingJ © 2025

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