// ==UserScript==
// @name play
// @namespace https://www.abc.com
// @version 0.2
// @description play
// @author reshuiping
// @match https://www.abc.com
// @require https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js
// ==/UserScript==
(function() {
'use strict';
// Your code here...
var sn=1;
var i=1;
$(document).ready(function(){
var iframe = document.createElement('iframe');
iframe.width=1024;
iframe.height=500;
iframe.id="d2gym"
iframe.name="d2gym"
iframe.align="middle"
document.body.appendChild(iframe);
setTimeout(function() {
$("#content_page").append("<button id='btn1' οnclick='PagingJump(\"li\",2,80,0)'>00</button>");
$("#btn1").trigger("click");
},2000);
autoplayvideo(1);
function autoplayvideo(ii) {
i=ii;
(function(i) {
console.log("starting play video");
sn=i;
setTimeout(function() {
console.log(i);
var course=$("#partail > div.NewCourseList > ul > li:nth-child(" + sn + ") > div.block4.fl > a");
course.attr("target","d2gym");
course.text("");
course.append("<span>cl</span>");
$("#partail > div.NewCourseList > ul > li:nth-child(" + sn + ") > div.block4.fl > a > span").trigger("click");
},4000);
$(document).ready(function(){
setTimeout(function(){
var jindu=$("#d2gym").contents().find("#cur_detail > table > tbody > tr:nth-child(5) > td.listtb2 > span").html();
if (jindu != "100%"){
$("#d2gym").contents().find("#cur_detail > table > tbody > tr:nth-child(5) > td.listtb3 > a").text("");
$("#d2gym").contents().find("#cur_detail > table > tbody > tr:nth-child(5) > td.listtb3 > a").append("<span>cl</span>");
$("#d2gym").contents().find("#cur_detail > table > tbody > tr:nth-child(5) > td.listtb3 > a").attr("target","d2gym");
$("#d2gym").contents().find("#cur_detail > table > tbody > tr:nth-child(5) > td.listtb3 > a > span").click();
setTimeout(function(){
var ref = "";
function mnop(){
var currenttime,endtime;
var videopage=$("#d2gym").contents().find("#mx-top").contents();
currenttime=$("#d2gym").contents().find("#mx-top").contents().find("#div-video_controlbar_elapsed").html();
//console.log(currenttime);
endtime=$("#d2gym").contents().find("#mx-top").contents().find("#div-video_controlbar_duration").html();
$("#d2gym").contents().find("#mx-top").contents().find("#show").remove();
$("#d2gym").contents().find("#mx-top").contents().find("#show2").remove();
$("#d2gym").contents().find("#mx-top").contents().find("#bg").remove();
$("#d2gym").contents().find("#mx-top").contents().find("#div-video_view > span.jwvideo > video").trigger('play');
if (currenttime==endtime) {
clearInterval(ref);
i=i+1;
sn=sn+1;
autoplayvideo(sn);
}
}
ref = setInterval(function(){
mnop();
},2000);
},8000);
}
},20000);
});
})(i);
}
});
})();