超星UnLock未学到的课程


该脚本用于解开超星慕课的所有课程节数。
用处自己想想吧。
食用方法:使用Chrome浏览器
                    打开看课的界面
                    按F12选择console
                    在下方的输入框内输入下方代码,回车
                    OK,见证奇迹。

(function() {
'use strict';
var foreach=function(ary,cb){
for(var i=0;i<ary.length;++i){
cb(i,ary[i]);
}
};
var targetWindow = window;
if(typeof unsafeWindow != 'undefined'){
targetWindow = unsafeWindow;
}
var targetDocument = targetWindow.document;
console.error('Script Start!');
var parseQueryString = function(str){
var map={};
var kvs=str.substring(1).split('&');
foreach(kvs,function(i,kv){
var kva=kv.split('=');
map[kva[0]]=kva[1];
});
return map;
};
var querys = parseQueryString(targetWindow.location.search);
var courseId = querys['courseId'];
var clazzid = querys['clazzid'];
targetWindow.courseId=courseId;
targetWindow.clazzid=clazzid;
var unlockOne=function(cell){
if(cell.children.length == 0)
return;
var a=cell.children[0];
if(a.href.startsWith('javascript:void')){
var h4=a.children[0];
var chapterId = h4.id.substring(3);
a.href='javascript:getTeacherAjax(\''+courseId+'\',\''+clazzid+'\',\''+chapterId+'\');';
h4.children[1].className='roundpointStudent';
}
};
var unlockAll=function(){
var ncells = targetDocument.getElementsByClassName('ncells');
foreach(ncells,function(i,cell){
unlockOne(cell);
});
console.log('Unlock All Chapters.');
};
targetWindow.unlockAll = unlockAll;
//setTimeout(unlockAll,1000);
var onReadComplete1 = function(){
var chapterId = document.getElementById("chapterIdid").value;
jQuery.ajax({
type: "get",
url : "/mycourse/studentstudycourselist",
dataType:'html',
data: {courseId:courseId,chapterId:chapterId,clazzid:clazzid},
success: function(data){
document.getElementById("coursetree").innerHTML=data;
jQuery(".ncells h4").removeClass();
jQuery(".ncells h5").removeClass();
jQuery("#cur"+chapterId).addClass("currents");
jQuery(".ncells .flush").css('display','none');
jQuery("#cur"+chapterId).parent().parent().find(".flush").css('display','block');
unlockAll();
}
});
};
var script = targetDocument.createElement('script');
script.innerText='onReadComplete1='+onReadComplete1.toString();
targetDocument.body.appendChild(script);
setTimeout(unlockAll,10);
setTimeout(function(){
top.document.onfocusin = null;
top.document.onfocusout = null;
top.onfocus = window.onfocus = null;
top.onblur = window.onblur = null;
},500);
console.error('Script End!');
})();

趁年轻,Just Do it!openwrt,php,js,html.....