Back to skills
extension
Category: Development & EngineeringNo API key required

codex学习tong自动答题

使用codex中的Chorme插件完成自动答题,打开你要考试的页面,对话中输入:使用自动答题工具 ,完成我现在已经打开的页面:xxx

personAuthor: z740739940hubModelScope

超星 考试自动答题 / Chaoxing Exam Auto-Answer

通过 CDP 连接到用户已有的 Chrome 浏览器,自动填写超星在线考试答案。

前置条件

  1. Chrome 已开启远程调试端口 9222
  2. 考试页面已在 Chrome 中打开(标签页 URL 包含 chaoxing.com/exam)
  3. 答案文件 chaoxing_answer_key.json 位于工作目录

答案文件格式

{
  "totalQuestions": 85,
  "answers": [
    { "q": 41, "type": "multi", "answer": ["A", "B", "C", "D"] },
    { "q": 56, "type": "judge", "answer": false },
    { "q": 20, "type": "single", "answer": "A" }
  ]
}
  • q: 题号
  • type: single / multi / judge
  • answer: 单选为字符串,多选为数组,判断 为 boolean

工作流程

  1. 使用 Playwright connectOverCDP() 连接到已有 Chrome(不关闭用户页面)
  2. 找到 URL 包含 chaoxing.com/exam 的标签页
  3. 逐一答题:识别当前题目 -> 查找答案 -> 点击对应选项 -> 点“下一题”
  4. 每道题间隔 0.5 秒

脚本使用

在工作目录下执行:

node <skill-path>/scripts/auto_answer.cjs [起始题号]

起始题号默认 41。脚本会自动跳过 BOM 读取答案文件。

页面结构关键点

详见 references/exam_structure.md

选择器原则

  • 不要用 .num_option_dx 或 .num_option 等具体 class 做选择器
  • 要用 span[data],所有题型选项的 span 都有 data 属性,值对应答案编码
  • 点击 .answerBg 父级 div 即可触发答题函数

常见问题

  • 文件 BOM: chaoxing_answer_key.json 可能含 UTF-8 BOM,读取后判断 charCodeAt(0) === 0xFEFF 并去除
  • 答案未保存: 检查选择器是否正确(用 span[data] 而非区分具体 class)
  • 导航被阻止: 确保点击选项后隐藏 input 的值已更新