🎉【U校园、Unipus网课答案显示】支持视听说新视野读写答案显示

U校园题目答案显示;支持视听说、新视野;不支持单元测试

  1. // ==UserScript==
  2. // @name 🎉【U校园、Unipus网课答案显示】支持视听说新视野读写答案显示
  3. // @namespace gongchen
  4. // @version 3.1
  5. // @description U校园题目答案显示;支持视听说、新视野;不支持单元测试
  6. // @author gongchen
  7. // @match *://ucontent.unipus.cn/_pc_default/pc.html?*
  8. // @connect *://ucontent.unipus.cn/*
  9. // @connect unipus.cn
  10. // @grant GM_xmlhttpRequest
  11. // @run-at document-end
  12. // @require https://lib.baomitu.com/jquery/3.6.0/jquery.min.js
  13. // @require https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.1.1/crypto-js.min.js
  14. // @antifeature ads 单元测试答案在app
  15. // @license MIT
  16. // ==/UserScript==
  17.  
  18. $('head').append('<link href="https://lib.baomitu.com/layui/2.6.8/css/layui.css" rel="stylesheet" type="text/css" />');
  19. $.getScript("https://lib.baomitu.com/layui/2.6.8/layui.js", function(data, status, jqxhr) {
  20. layui.use('element', function(){
  21. var element = layui.element;
  22. });
  23. layer.closeAll();
  24. show();
  25. showanswer();
  26. });
  27.  
  28. // 感谢ssmjae提供的解密代码
  29. function decryptContent(json) {
  30. if (json) {
  31. let r = json.content.slice(7)
  32. , o = CryptoJS.enc.Utf8.parse("1a2b3c4d" + json.k)
  33. , i = CryptoJS.enc.Hex.parse(r)
  34. , a = CryptoJS.enc.Base64.stringify(i)
  35. , contentJson = JSON.parse(CryptoJS.AES.decrypt(a, o, {
  36. mode: CryptoJS.mode.ECB,
  37. padding: CryptoJS.pad.ZeroPadding
  38. }).toString(CryptoJS.enc.Utf8));
  39. json = contentJson;
  40. console.log(json);
  41. }
  42. return json;
  43. }
  44.  
  45. var show = ()=>{
  46. layer.open({
  47. type: 1,
  48. area: ['500px', '600px'],
  49. offset: 'l',
  50. id: 'msgt',
  51. closeBtn: 1,
  52. title: "U校园网课助手(答案显示,支持单选、多选、填空、简答、问答)",
  53. shade: 0,
  54. maxmin: true,
  55. anim: 2,
  56. content:'<div class="layui-collapse"><div class="layui-colla-item"><h2 class="layui-colla-title">公告</h2><div class="layui-colla-content layui-show">脚本已修复普通测试答案获取,单元测试的相关答案已录入app<img src="https://d2.ananas.chaoxing.com/download/feac612889547d337f651b219c7fb219?at_=1731486793172&ak_=348c90275cd7177a97ae69b0cb0376a6&ad_=3a92768cb747ef62b8b80b1ac716fca1" width="300px" /></div>'+
  57. '</div></div>'+
  58. '<div id="content"><ul></ul><table class="layui-table"> <colgroup> <col width="100"> <col> <col> </colgroup> <thead> <tr> </tr> </thead> <tbody> </tbody> </table></div></div></div>'
  59. });
  60. }
  61.  
  62. let isShow = true
  63. var showanswer = ()=>{
  64. if (isShow){
  65. let url = location.href
  66. let arr = url.split("/")
  67. let book = arr[arr.length-7]
  68. let unit = arr[arr.length-2]
  69. let answer = []
  70. GM_xmlhttpRequest({
  71. method: 'GET',
  72. url: 'https://ucontentapi.unipus.cn/course/api/content/'+book+'/'+unit+'/default/',
  73. headers: {
  74. 'X-ANNOTATOR-AUTH-TOKEN': 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJvcGVuX2lkIjoidHV4NkNCQVc4aGRrcnFZdzc5SEpEWDF2aTR5Z2ptcDUiLCJuYW1lIjoiIiwiZW1haWwiOiIiLCJhZG1pbmlzdHJhdG9yIjoiZmFsc2UiLCJleHAiOjE5MDI5NzAxNTcwMDAsImlzcyI6IlI0aG03RmxQOFdvS0xaMUNmTkllIiwiYXVkIjoiZWR4LnVuaXB1cy5jbiJ9.CwuQmnSmIuts3hHAMf9lT954rKHXUNkps-PfRJp0KnU'
  75. },
  76. timeout: 5000,
  77. onload: function(xhr) {
  78. if (xhr.status == 200) {
  79. let el = '<tr class="layui-bg">' + '</td></tr>'
  80. console.log('https://ucontentapi.unipus.cn/course/api/content/'+book+'/'+unit+'/default/')
  81.  
  82. console.log(xhr.responseText)
  83. let obj = JSON.parse(xhr.responseText) || {};
  84. let deObj = decryptContent(obj);
  85. let keyList = Object.keys(deObj);
  86. console.log(keyList)
  87. Array.prototype.contains = function (obj) {
  88. var index = this.length;
  89. while (index--) {
  90. if (this[index] === obj) {
  91. return true;
  92. }
  93. }
  94. return false;
  95. }
  96. // 选择题
  97. if (keyList.contains('questions:questions')){
  98. let questionList = deObj['questions:questions'].questions
  99. for (let question of questionList){
  100. let result = ''
  101. if (question.answers){
  102. result += question.answers.join(' ')
  103. }
  104. el = el + '<td>' + result + question.analysis.html + '</td></td></tr>'
  105. }
  106. }
  107. // 简答题
  108. if (keyList.contains('shortanswer:shortanswer')){
  109. let questionList = deObj['shortanswer:shortanswer'].questions
  110. for (let question of questionList){
  111. el = el + '<td>' + deObj['shortanswer:shortanswer'].analysis.html + question.content.html + question.analysis.html + '</td></td></tr>'
  112. }
  113. }
  114. // 填空题
  115. if (keyList.contains('questions:scoopquestions')){
  116. let questionList = deObj['questions:scoopquestions'].questions
  117. for (let question of questionList){
  118. let result = ''
  119. if (question.answers){
  120. result += question.answers.join(' ')
  121. }
  122. el = el + '<td>' + result + question.analysis.html + '</td></td></tr>'
  123. console.log(el)
  124. }
  125. }
  126. // 短回答题
  127. if (keyList.contains('questions:shortanswer')){
  128. let questionList = deObj['questions:shortanswer'].questions
  129. for (let question of questionList){
  130. let result = ''
  131. if (question.answers){
  132. result += question.answers.join(' ')
  133. }
  134. el = el + '<td>' + result + question.analysis.html + '</td></td></tr>'
  135. }
  136. }
  137. el = el + '<td>答案结束,没答案就是没适配,请使用app</td></td></tr>'
  138. $("#content>table>tbody").append($(el));
  139. }
  140. }
  141. });
  142. }
  143. isShow = !isShow
  144. }
  145.  
  146. window.onhashchange=()=>{
  147. $("#content>table>tbody").empty();
  148. showanswer();
  149. }

QingJ © 2025

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