背景
学习公社平台学习中,需要人工干预才可以连续学习。
解方
安装油猴
省略
导入脚本
// ==UserScript==
// @name 学习公社平台
// @namespace http://tampermonkey.net/
// @version 0.3
// @description try to take over the world!
// @AuThor You
// @match https://study.enaea.edu.cn/viewerforccvideo.do?courseId=*&circleId=*
// @Icon https://www.google.com/s2/favicons?domain=enaea.edu.cn
// @grant none
// ==/UserScript==
(function() {
'use strict';
let isLast = false;
function gotoNext(){
let todos = opener.$('table.dataTable tr:contains(%)').filter((i,v)=>{ return $(v).find('td:nth-child(4)').text().indexOf('#') == -1 && $(v).find('td:nth-child(5)').text().indexOf('100%') == -1})
.filter((i,v)=>{ let vurl = $(v).find('a.saveStuCourse').attr('data-vurl'); return location.href.indexOf(vurl) == -1});
if(todos.length > 0){
console.log('switch to next.... reload ');
let nextCourse = $(todos[0]);
nextCourse.find('td').eq(3).text('#')
let nextVurl = nextCourse.find('a.saveStuCourse').attr('data-vurl');
location.href = nextVurl;
}
}
function autoSetEvent(){
setInterval(function(){
var aud = $("div video").get(0);
if( $(aud).prop('__ok__') != true){
aud.addEventListener("ended", video_ended);
console.log("add ended event listener.")
$(aud).prop('__ok__',true);
isLast = $('ul.cvtb-MCK-course-list li.last').text() == $('ul.cvtb-MCK-course-list li.current').text();
let notStudyList = $('div.cvtb-MCK-CsCt-studyProgress').filter((i,v)=>$(v).text().indexOf('100%') == -1);
if(notStudyList.length == 0){
gotoNext();
}
else if(notStudyList.length > 0 && $('ul.cvtb-MCK-course-list li.current').find('div.cvtb-MCK-CsCt-studyProgress').text().indexOf('100%') === 0){
notStudyList.eq(0).parent().click();
}
}
$('.dialog-button-container button:contains(继续学习)').click()
},3000);
}
function video_ended() {
console.log("The audio has ended");
if(isLast){
console.log('switch to next.... ');
gotoNext();
}
}
setTimeout(function(){
// debugger;
$(".continue .user_choise").click()
autoSetEvent();
},3000);
// Your code here...
})();
|