现在在国家开放大学上学习,面对形考任务的时候,一是要靠对教材的认真学习,二要靠搜索引擎。但是我发现在搜索引擎上绝大部分的参考答案的文档都要付费,感觉有点不开心。于是在自己完成部分考试后,对开考回顾的页面进行脚本采集,在控制台直接打到markdown格式的文本,然后进行分享。
分享的目的不是为了抄答案,而是在以答题的形式的过程中,提供相对正确的参考,帮助学习。
// ==UserScript==
// @name 国开回顾
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match http://chengdu.ouchn.cn/mod/quiz/review.php?attempt=*&cmid=*
// @icon https://www.google.com/s2/favicons?domain=ouchn.cn
// @grant none
// ==/UserScript==
(function() {
'use strict';
var res = "";
$(".que").each(function(){
var que = $(this);
var bt = que.find(".info .no").text();
res += "\n";
res += "\n";
if(bt.indexOf("信息")<0){
res += bt+" ";
} else {
res += "## ";
}
que.find(".formulation").each(function(){
var _this = $(this);
var qtext = _this.find(".qtext");
var prompt = _this.find(".prompt");
var answer = _this.find(".answer");
if(qtext.length>0) {
res += qtext.text();
res += "\n";
}
if(prompt.length>0) {
// res += prompt.text();
// res += "\n";
}
if(answer.length>0){
answer.children().each(function(){
var cc = $(this);
if(cc.hasClass("correct")){
res += "<span style='color:red'>"+cc.text()+"</span>";
res += "\n";
} else {
res += cc.text();
res += "\n";
}
});
}
});
});
console.log(res);
})();