NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name 智慧树答案自动获取 // @namespace https://ddosolitary.org/ // @version 0.2 // @author DDoSolitary // @match https://onlineexamh5new.zhihuishu.com/stuExamWeb.html // @grant none // @license MIT // @updateURL https://openuserjs.org/meta/DDoSolitary/智慧树答案自动获取.meta.js // ==/UserScript== (function() { 'use strict'; var id; function getAnswers() { var questions = document.getElementsByClassName('examPaper_subject'); if (questions.length === 0) { return; } else { clearInterval(id); } var cookie = document.cookie.split(';').find(function(s) { return s.trim().startsWith('CASLOGC='); }); var uuid = JSON.parse(decodeURIComponent(cookie.split('=')[1])).uuid; var queries = []; for (var i = 0; i < questions.length; i++) { var question = questions.item(i); var options = question.querySelectorAll('input[type=radio], input[type=checkbox]'); var optionIds = []; for (var j = 0; j < options.length; j++) { optionIds.push(options.item(j).value); } queries.push({ optionsIdStr: optionIds.join(','), questionId: parseInt(question.querySelector('.subject_num span').id.substr(7)) }); } var xhr = new XMLHttpRequest(); xhr.open('POST', 'https://studentexam.zhihuishu.com/studentExam/answer/getAnswerImgInfo', true); xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); xhr.withCredentials = true; xhr.onload = function() { if (xhr.status !== 200) return; var response = JSON.parse(xhr.response); if (response.status !== '200') return; for (var i = 0; i < questions.length; i++) { var question = questions.item(i); if (question.parentElement.getElementsByClassName('reviewList').length > 0) { continue; } var img = new Image(); img.src = response.rt[parseInt(question.querySelector('.subject_num span').id.substr(7))]; img.style.width = '100%'; question.appendChild(img); } }; xhr.send('optionSortInfo=' + encodeURIComponent(JSON.stringify(queries)) + '&uuid=' + uuid); } id = setInterval(getAnswers, 1000); })();