说明
仅供学习交流
法宣在线考试, 自动获取答案, 完成考试.
使用方法
使用chrome浏览器登录法宣在线, 进入考试页面;
单击浏览器的地址栏, 按快捷键F12; 或者使用菜单: 更多工具 – 开发者工具;
定位到console/控制台面板, 粘贴代码, 回车;
程序开始执行, 每秒答一道题, 等待答题完成;
代码
var answer = [];
var times = 0;
var totalTimes = 0;
var Next = function () {
var questionId = answer[times]['questionId']
console.log("questionId", questionId)
$(`[id$=_${questionId}]`).click();
setTimeout(
function () {
var strAns = answer[times]['answerNo'];
var arrA = strAns.split('');
for (a of arrA) {
console.debug(a);
$('input[value=' + a + ']').click()
}
times += 1;
if (times < totalTimes) {
Next();
}
else {
console.debug('完成');
}
}, 1000);
};
var start = function () {
console.debug('开始');
let cookie = document.cookie;
let matchArray = cookie.match(/_EXAM(\d+)_PAPER(\d+)_SERIES(\d+)/);
let examId = matchArray[1];
let paperId = matchArray[2];
let seriesId = matchArray[3];
let answerUrl = `http://www.faxuanyun.com//ess/service/getpaper?paperId=${paperId}&series=${seriesId}_answer`
fetch(answerUrl, {
"headers": {
"cache-control": "no-cache",
"pragma": "no-cache",
"upgrade-insecure-requests": "1"
},
"referrerPolicy": "strict-origin-when-cross-origin",
"body": null,
"method": "GET",
"mode": "cors",
"credentials": "include"
}).then(res => res.text()).then(body => {
console.debug("test", body);
let answerString = body.split("\n")[2];
answer = JSON.parse(answerString);
totalTimes = answer.length;
Next();
});
}
start();
原理
这个地址可以获取到考试的答案: http://xf.faxuan.net/ess/service/getpaper?paperId=${paperId}&series=${seriesId}_answer
最新评论