聲明:非原創,代碼來源於網絡
【F12→Console粘貼后回車】
1 function playVideo(){ 2 let iframe=$("#iframe").contents().find("iframe").contents(); 3 let video=iframe.find("#video_html5_api")[0];//找到video對象 4 if(video == undefined){ 5 console.log("沒有找到視頻播放器"); 6 return; 7 } 8 video.play();//播放 9 video.muted=true;//靜音 10 video.playbackRate=2;//倍速播放 此處2速率播放 11 let text=$(".ncells .currents .hideChapterNumber").text().trim(); 12 var tid=window.setInterval(function(){ 13 let ul=iframe.find(".ans-videoquiz-opts:visible"); 14 if(ul){//有題目出現 15 iframe.find(".ans-videoquiz-opts input[value='true']").attr("checked",true); 16 iframe.find(".ans-videoquiz-submit").trigger("click");//ext-gen1045 17 } 18 if(video.ended){//視頻播放完 19 console.log(text+"節已播放完") 20 if($(".ncells .currents .roundpointStudent").hasClass("blue")){ 21 console.log(text+"節任務點已完成") 22 let curr=$('.ncells .jobCount').first().next(); 23 if(curr==undefined){ 24 console.log('課程已看完'); 25 clearInterval(tid); 26 return; 27 } 28 curr.click(); 29 let fun=curr.attr('href').substr(11); 30 eval(fun); 31 window.setTimeout(function(){ 32 console.log("正在為你自動播放下一個視頻"); 33 clearInterval(tid); 34 playVideo(); 35 },5000); 36 } 37 return; 38 } 39 }, 5000); 40 41 $("div").onmouseout=function(){ 42 video.play(); 43 return true; 44 } 45 } 46 function start(){ 47 let curr=$('.ncells .jobCount').first().next(); 48 if(curr==undefined){ 49 console.log('課程已看完'); 50 clearInterval(tid); 51 return; 52 } 53 curr.click(); 54 let fun=curr.attr('href').substr(11); 55 eval(fun); 56 window.setTimeout(function(){ 57 playVideo(); 58 },5000); 59 } 60 start();
注:對於鼠標移開界面,視頻就暫停播放的解決方案:
F12→Elements→Event Listener→mousemove→window 選擇remove