Skip to content

Instantly share code, notes, and snippets.

@no1xsyzy
Last active May 17, 2018 19:00
Show Gist options
  • Save no1xsyzy/1d2111b54d4464b116f9798de52942f6 to your computer and use it in GitHub Desktop.
Save no1xsyzy/1d2111b54d4464b116f9798de52942f6 to your computer and use it in GitHub Desktop.
Run with console in video page
// uses in console
// URL should be like <http://wanke001.com/User/Student/ClassIndex.aspx?ClassID=*&action=courseList>
var timelength = function(txt){
var [m, s] = txt.split(":");
return +m + (+s)/60;
}
var data = $$('section.PhaseDetaillist[contenttype="1"]')
.filter(x=>x.lastElementChild.firstElementChild.firstElementChild.firstElementChild)
.map(x=>([
x.firstElementChild.innerText, // title
+x.getAttribute('phasedetailid'), // pdid
timelength(x.lastElementChild.lastElementChild.firstElementChild.innerText) // totalTime
]))
.reverse();
classid = +/[&?]ClassID=(\d+)/.exec(window.location.search)[1];
document.querySelector("body").outerHTML='<div id="echo"></div>';
var echo = text=>{document.getElementById("echo").innerText+=text+"\n"};
var title, pdid, totalTime, currectTime;
var pick = ()=>{
if(data.length > 0){
[title, pdid, totalTime] = data.pop();
currectTime=0;
echo("on ("+pdid+") "+title);
return true;
}else{
return null;
}
};
pick();
var notoken = setInterval(()=>{
currectTime+=1;
echo(Math.round(currectTime)+" minute(s) past");
$.ajax({
async: true,
url: "/Handler/User/VideoPlay.ashx",
data: { "DoType": "UpdatePlayProgress", "PhaseDetailID": $.base64.encode(pdid), "CurrentSeconds": $.base64.encode(currectTime*60),
"WatchSeconds": $.base64.encode(currectTime*60), "ClassID": $.base64.encode(classid), "UpdateType": $.base64.encode(0)
},
dataType: 'text',
type: 'post',
success: function (result) {
}
});
if(currectTime>totalTime * 0.6){
echo("done");
if(!pick()){
clearInterval(notoken);
}
}
}, 60000);
// uses in console
// URL should be like <http://wanke001.com/User/Student/CourseStudy.aspx?ClassID=*&PhaseDetailID=*>
var totalTime = $("video")[0].duration;
document.querySelector("section.videoPlayer").outerHTML='<div id="echo"></div>';
var echo = text=>document.getElementById("echo").innerText+=text+"\n";
window.videoPlayer = {currentTime:0,on:(ev,cb)=>{},pause:()=>{},play:()=>{}};
alert = echo;
var notoken = setInterval(()=>{
totalWatchSeconds+=60;
videoPlayer.currentTime+=60;
echo(Math.round(videoPlayer.currentTime / 60)+" minute(s) past");
updatePlayTime(0);
if(videoPlayer.currentTime>totalTime * 0.6){
clearInterval(notoken);
echo("done");
}
}, 60000);
echo("Lucky " + Math.ceil(totalTime / 100) + " minute(s)");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment