文章目录
目的
- 本脚本主要是辅助会计继续教育官网视频学习, 能够自动答题. 避免为凑足观看学时而一直值守观看的烦恼.
- 脚本需要放在浏览器插件Tampermonkey中执行.
// ==UserScript==
// @name answering
// @namespace http://jxjyxuexi.chinaacc.com
// @version 0.1
// @description try to take over the world!
// @author lei
// @match http://jxjyxuexi.chinaacc.com/CourseWare/*
// @grant none
// ==/UserScript==
function answering() {
// get correct answer!
var ret = commit_user_select("");
if (!ret || !ret.firstChild)
return;
var ans = ret.firstChild.innerHTML;
var ajh = ans.indexOf('。');
if (6<ans.length && ajh>5) {
ans = ans.slice(5, ajh);
if (ans === '错')
ans = 'N';
else if (ans === '对')
ans = 'Y';
// post our answer
commit_user_select(ans);
}
}
function commit_user_select(useranswervalue) {
// parent node must exist!
if (!document.getElementById('videoPointContent'))
return null;
// var useranswer = document.getElementsByName("useranswer");
// var useranswervalue = "";
// for (var i = 0; i < useranswer.length; i++) {
// if (useranswer[i].checked) {
// useranswervalue += useranswer[i].value;
// }
// }
//var pointTestUrl = "/CourseWare/1642430/9530/3434/video/PointTest";
//var nowVideoID = "0101";
var strUrl = pointTestUrl + "?rnd=" + Math.random();
try {
var xmlHttp = new XMLHttpRequest();
var sdata = "testid=" + document.pointform.testid.value + "&useranswer=" + useranswervalue +
"&pointnum=" + document.pointform.pointnum.value + "&forumid=" + document.pointform.forumid.value +
"&questionid=" + document.pointform.questionid.value + "&pointtype=" + document.pointform.pointtype.value +
"&newpointid=" + document.pointform.newpointid.value + "&videoid=" + nowVideoID;
xmlHttp.open("Post", strUrl, false);
xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xmlHttp.send(sdata);
//xmlHttp.addEventListener();
if (xmlHttp.status == 200) {
var xmlDoc = xmlHttp.responseText;
eval("var obj =" + xmlDoc);
if (obj.Results == "1") {
document.getElementById("videoPointBg").style.display = "none";
document.getElementById("videoPoint").style.display = "none";
setValidTime(obj.MaxPlayTime);
playVideo();
} else {
document.getElementById("PointQuestionAnswer").innerHTML = obj.ReturnStr;
return document.getElementById("PointQuestionAnswer");
}
}
return null;
} catch (e) {
return null;
}
}
(function() {
setInterval(answering, 3000);
})();