exam

exam faster

  1. // ==UserScript==
  2. // @name exam
  3. // @description exam faster
  4. // @namespace http://tampermonkey.net/
  5. // @version 0.4
  6. // @author You
  7. // @match https://l.jd.com/student/exam/analyze.du*
  8. // @match https://l.jd.com/student/exam/exam.du*
  9. // @icon https://www.google.com/s2/favicons?sz=64&domain=jd.com
  10. // @grant GM_setClipboard
  11. // @license MIT
  12. // ==/UserScript==
  13. ;(function () {
  14. "use strict"
  15. let answersMap
  16. const paper = document.querySelector('.jdu-exam')
  17. const btnCtn = document.createElement("div")
  18. btnCtn.className = "jdu-btn-con";
  19. btnCtn.style.position = "fixed";
  20. paper.appendChild(btnCtn)
  21.  
  22. const btn = document.createElement("a")
  23. btn.href = "#"
  24. btn.innerText = "Go!"
  25.  
  26. btnCtn.appendChild(btn)
  27. setTimeout(() => {
  28. if (location.pathname.endsWith("analyze.du")) {
  29. btn.addEventListener("click", () => {
  30. const questions = document.querySelectorAll(".question")
  31. const map = {}
  32.  
  33. Array.from(questions).map((question) => {
  34. const questionId = question.id
  35. const options = Array.from(
  36. question.querySelectorAll(".answer-options li")
  37. )
  38. const answersStr = question
  39. .querySelector(".jdu-answer-analyze > div:first-child")
  40. .innerText.substr(5)
  41. map[questionId] = answersStr.split("").reduce((prev, answerKey) => {
  42. const answerStr = options.find(
  43. (option) => option.innerText[1] == answerKey
  44. )
  45. const answer = answerStr.innerText.substr(1)
  46. prev.push(answer.trim().replace(/^ ?[ABCDEFGH]\. ?/, ""))
  47. return prev
  48. }, [])
  49. })
  50. GM_setClipboard(JSON.stringify(map), "text", () => alert("已复制"));
  51. })
  52. }
  53.  
  54. if (location.pathname.endsWith("exam.du")) {
  55. btn.addEventListener("click", () => {
  56. const questions = document.querySelectorAll(".question")
  57. if (!answersMap) {
  58. answersMap = JSON.parse(prompt("请粘贴参考答案:"))
  59. }
  60.  
  61. questions.forEach((question) => {
  62. const answers = answersMap[question.id] || []
  63. const options = question.querySelectorAll(".answer-options li")
  64. options.forEach((option) => {
  65. const purifiedOption = option.innerText
  66. .trim()
  67. .replace(/^ ?[ABCDEFGH]\. ?/, "")
  68. if (
  69. answers.some((answer) => {
  70. return answer === purifiedOption
  71. })
  72. ) {
  73. option.click()
  74. }
  75. })
  76. })
  77. })
  78. }
  79. }, 1000)
  80. })()

QingJ © 2025

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