会计继续教育更优雅的方式
最近又开始了会计继续教育这个事情了。每年要做,还要时不时的答题,不答题不累计时间,这不是把人给栓在电脑旁么?这可不是我想要的。let's do it。
必备工具:firefox tampermonkey node.js whistle 集齐四个龙珠,召唤神龙。哦不,集齐四个工具,攻破会计继续教育。
步骤略解:
安装firefox浏览器,并且安装tampermonkey、FoxyProxy 这两个扩展。
安装node.js,然后使用下面的命令行指令安装其他需要的工具:
npm install -g whistle
npm install -g whistle.script然后打开命令行,执行下面的指令:
w2 run打开firefox,输入 http://127.0.0.1:8899/ 进入代理界面。
在插件界面新建个脚本,输入如下内容:
exports.handleRequest = function* (ctx,next){
const {statusCode,headers} = yield next();
const resText = yield ctx.getResText();
const fs = require('fs');
if (ctx.fullUrl.indexOf('/c/public/showflashvideo.jsp')!==-1){
const regex1 = /var a_coursename = "(.*)"/gm; //课程名字
const regex2 = /var o_single = (\[.*\])/gm; //单选题
const regex3 = /var o_judge = (\[.*\])/gm; //多选题
let m,j,k;
while ((m = regex1.exec(resText)) !== null) {
// This is necessary to avoid infinite loops with zero-width matches
if (m.index === regex1.lastIndex) {
regex1.lastIndex++;
}
console.log("课程名字:" + m[1])
fs.appendFileSync('F:/20180613/kj.txt',"课程名字:" + m[1] + '\r\n\r\n','utf8');
}
while ((j = regex2.exec(resText)) !== null) {
if (j.index === regex2.lastIndex) {
regex2.lastIndex++;
}
//console.log("选择题:" + j[1]);
let obj = JSON.parse(j[1])
//console.log(obj);
let temparr = obj;
let r = getanswer(temparr)
r.forEach(function (item, index, array) {
fs.appendFileSync('F:/20180613/kj.txt',item + '\r\n','utf8');
});
}
while ((k = regex3.exec(resText)) !== null) {
if (k.index === regex3.lastIndex) {
regex3.lastIndex++;
}
//console.log("判断题:" + k[1]);
let obj = JSON.parse(k[1])
//console.log(obj);
let temparr = obj;
let r = getanswer(temparr)
r.forEach(function (item, index, array) {
fs.appendFileSync('F:/20180613/kj.txt',item + '\r\n','utf8');
});
}
}
};
function getanswer(arr)
{
let result = []
arr.forEach(function (item, index, array) {
//console.log(item, index);
console.log(item['t']); //题目
result.push(item['t']);
//答案的判定
switch(item['a'])
{
case "A":
console.log("答案:" + item['o'][0]);
result.push("答案:" + item['o'][0] + '\r\n');
break;
case "B":
console.log("答案:" + item['o'][1]);
result.push("答案:" + item['o'][1] + '\r\n');
break;
case "C":
console.log("答案:" + item['o'][2]);
result.push("答案:" + item['o'][2] + '\r\n');
break;
default:
console.log("答案:" + item['o'][3]);
result.push("答案:" + item['o'][3] + '\r\n');
}
console.log("\n") //每题空一行
});
return result;
}
在规则窗口建个一个规则,内容为
script://kuaiji /c/public/showflashvideo.jsp/ disable://cache其他请看视频演示。