Greasy Fork is available in English.
学时刷不完?
当前为
// ==UserScript==
// @name 网上学院-学时助手2.0
// @namespace none
// @version 0.2
// @description 学时刷不完?
// @author wyc
//首页
// @match http://wsxy.chinaunicom.cn/learner/home
//课程列表
// @match http://wsxy.chinaunicom.cn/learner/subject
// @match http://wsxy.chinaunicom.cn/learner/subject/*
//课程详情
// @match http://wsxy.chinaunicom.cn/learner/course/detail/*
//课程播放
// @match http://wsxy.chinaunicom.cn/learner/play/course/*
// @grant none
// @run-at document-end
// @require https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js
// ==/UserScript==
(function () {
var currentURL = window.location.href; // 获取当前网页地址
console.log('当前网页',currentURL);
console.log(new Date())
window.setTimeout(()=>{
if( currentURL.indexOf('learner/home')>= 0){
console.log('首页');
// window.location.href="http://wsxy.chinaunicom.cn/learner/subject/49659088/detail";
}
else if( currentURL.indexOf('/subject/49659088/detail')>= 0){
console.log('列表');
seleCourse(); // 选择课程
}//http://wsxy.chinaunicom.cn/learner/subject 专题栏
else if( currentURL.indexOf('learner/subject')>= 0){
console.log('专题栏');
window.open('http://wsxy.chinaunicom.cn/learner/subject/49659088/detail','_self');
seleCourse(); // 选择课程
}
else if( currentURL.indexOf('course/detail')>= 0){
console.log('详情');
detailOp();
}
else if( currentURL.indexOf('play/course')>= 0){
console.log('播放');
palylOp();
}
},1500);
/**
* 课程列表 选择课程
*/
function seleCourse() {
window.frames.document.querySelectorAll("div[class=right] span")[1].click();
window.setTimeout(()=>{
toStudy();
},1000)
function toStudy(){
var $courseDivs = $("div[class='course-content clearfix'] div")
console.log('当前课程列表链接',$courseDivs.find('a')[0]);
$courseDivs.find('a')[0].click();
}
};
/*
详情页面操作
*/
function detailOp(){
window.setTimeout(()=>{
$("button[class='course-button ant-btn ant-btn-default']").click(); //开始学习 单课程
$("button[class='ant-btn course-button ant-btn-default']").click();//开始学习 多课程
},1000)
window.setTimeout(()=>{
palylOp();
},5000)
};
/*
播放页面操作
*/
function palylOp(){
var endFlag = false;
var items = $("div[class = 'course-text']") //课程视频
var num = items.length;
console.log('视频数',num);
setInterval(()=>{
var result = $('#cmi-frame').prop('contentWindow').document;
// console.log($($(result.getElementById("video")).children().children()[3]));
let playControls = $($(result.getElementById("video")).children().children()[3]).children() //控制条
$(playControls[16]).click(); //静音
$("button[class='save-logout-box ant-btn ant-btn-primary']").click();//保存学习记录
/*
if($(this).find("div.course-single.clearfix.active-s").length>0 && index == (num-1)){
//播放最后一个视频;
endFlag = true;
console.log('end..video..');
let timeText = $(playControls[7]).html();//播放时长 12:49 / 78:03
let currTime = timeText.split(" / ")[0]
let totalTime = timeText.split(" / ")[1]
console.log(currTime,totalTime);
if(totalTime == currTime){
window.open('http://wsxy.chinaunicom.cn/learner/subject/49659088/detail','_blank');
}
}
*/
items.each(function(index){
console.log(index);
if($(this).find("div.course-single.clearfix.active-s").length>0 && index == (num-1)){
//播放最后一个视频;
endFlag = true;
console.log('end....',index);
let timeText = $(playControls[7]).html();//播放时长 12:49 / 78:03
let currTime = timeText.split(" / ")[0]
let totalTime = timeText.split(" / ")[1]
console.log(currTime,totalTime);
if(totalTime == currTime){
window.open('http://wsxy.chinaunicom.cn/learner/subject/49659088/detail','_self');
}
// window.open('http://wsxy.chinaunicom.cn/learner/subject/49659088/detail','_blank');
}
});
},5000);
}
function checkItem(){
}
})();