🏠 Home 

[蓝墨云] 复习时高亮显示正确的选项

显示正确的选项方便复习


Install this script?
  1. // ==UserScript==
  2. // @name [蓝墨云] 复习时高亮显示正确的选项
  3. // @namespace ckylin-script-mosoteach-showsinglecurrectanswer
  4. // @version 0.4
  5. // @description 显示正确的选项方便复习
  6. // @author CKylinMC
  7. // @match https://www.mosoteach.cn/*
  8. // @grant none
  9. // @license MIT
  10. // ==/UserScript==
  11. (function() {
  12. 'use strict';
  13. let highlighted = false;
  14. function highlightCurrectAnswers(){
  15. if(highlighted) return; else highlighted = true;
  16. const get = (q,p=document.body) => p.querySelector(q);
  17. const getAll = (q,p=document.body) => p.querySelectorAll(q);
  18. const list = get(".main-box .topic-list");
  19. const items = getAll(".topic-item",list);
  20. const ansMap = ['A','B','C','D','E','F','G','H','I','J','K'];
  21. for(let it of items){
  22. try{
  23. const choices = [...getAll(".t-option.t-item>.opt",it)];
  24. const currect = get(".t-answer.t-item>.answer-l>.light",it);
  25. const answers = currect.innerHTML.trim().split('');
  26. const indexes = [];
  27. for(let ans of answers){
  28. let ind = ansMap.indexOf(ans.toUpperCase());
  29. if(ind>=0 && !indexes.includes(ind)) indexes.push(ind);
  30. }
  31. choices.forEach((el,ind)=>{
  32. if(!indexes.includes(ind)){
  33. el.style.opacity = ".1";
  34. el.style.fontSize = "smaller";
  35. }else{
  36. el.style.fontSize = "larger";
  37. }
  38. })
  39. }catch(Exception){}
  40. }
  41. }
  42. function customcss(yes=true){
  43. const old = document.querySelector("#notbottomcss");
  44. old&&old.remove();
  45. if(yes){
  46. const css = document.createElement("style");
  47. css.appendChild(document.createTextNode(`
  48. .t-con>.t-info.t-item{
  49. display:none !important;
  50. }
  51. .t-con>.t-subject{
  52. font-weight:bold !important;
  53. font-size:large !important;
  54. }
  55. .t-bottom{
  56. display:none !important;
  57. }
  58. .t-top{
  59. padding-bottom: 20px !important;
  60. }
  61. `));
  62. css.id = "notbottomcss";
  63. document.body.appendChild(css);
  64. }
  65. }
  66. function isContentReady(){
  67. return document.querySelector(".topic-list")!==null;
  68. }
  69. let timer = null;
  70. function loader(){
  71. if(!isContentReady()){
  72. if(timer===null){
  73. timer = setInterval(loader,200);
  74. }else{
  75. console.log("Waiting...");
  76. }
  77. }else{
  78. clearInterval(timer);
  79. customcss();
  80. highlightCurrectAnswers();
  81. }
  82. }
  83. if(document.title.indexOf("查看个人解析")>=0)loader();
  84. })();