'
});
}
let isShow = true
var showanswer = () => {
if (isShow) {
let url = location.href;
let arr = url.split("/");
let book = arr[arr.length - 7];
let unit = arr[arr.length - 2];
let answer = [];
GM_xmlhttpRequest({
method: 'GET',
url: 'https://ucontentapi.unipus.cn/course/api/content/' + book + '/' + unit + '/default/',
headers: {
'X-ANNOTATOR-AUTH-TOKEN': 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJvcGVuX2lkIjoidHV4NkNCQVc4aGRrcnFZdzc5SEpEWDF2aTR5Z2ptcDUiLCJuYW1lIjoiIiwiZW1haWwiOiIiLCJhZG1pbmlzdHJhdG9yIjoiZmFsc2UiLCJleHAiOjE5MDI5NzAxNTcwMDAsImlzcyI6IlI0aG03RmxQOFdvS0xaMUNmTkllIiwiYXVkIjoiZWR4LnVuaXB1cy5jbiJ9.CwuQmnSmIuts3hHAMf9lT954rKHXUNkps-PfRJp0KnU'
},
timeout: 5000,
onload: function(xhr) {
if (xhr.status == 200) {
let el = '
' + '
';
console.log('https://ucontentapi.unipus.cn/course/api/content/' + book + '/' + unit + '/default/');
console.log(xhr.responseText);
let obj = JSON.parse(xhr.responseText) || {};
let deObj = decryptContent(obj);
let keyList = Object.keys(deObj);
console.log(keyList);
Array.prototype.contains = function(obj) {
var index = this.length;
while (index--) {
if (this[index] === obj) {
return true;
}
}
return false;
};
let questionNumber = 1; // 用于题目序号
// 选择题
if (keyList.contains('questions:questions')) {
let questionList = deObj['questions:questions'].questions;
for (let question of questionList) {
let result = '';
if (question.answers) {
result += question.answers.join(' ');
}
el += '
';
questionNumber++;
}
}
// 简答题
if (keyList.contains('shortanswer:shortanswer')) {
let questionList = deObj['shortanswer:shortanswer'].questions;
for (let question of questionList) {
let content = question.content.html;
el += '
';
questionNumber++;
}
}
// 填空题
if (keyList.contains('questions:scoopquestions')) {
let questionList = deObj['questions:scoopquestions'].questions;
for (let question of questionList) {
let result = '';
if (question.answers) {
result += question.answers.join(' ');
}
el += '
';
questionNumber++;
console.log(el);
}
}
// 短回答题
if (keyList.contains('questions:shortanswer')) {
let questionList = deObj['questions:shortanswer'].questions;
for (let question of questionList) {
let result = '';
if (question.answers) {
result += question.answers.join(' ');
}
el += '