// ==UserScript==
// @name 平台培训
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match
// @match
// @icon
// @grant none
// ==/UserScript==
(function() {
'use strict';
console.log('脚本开始运行!');
//console.log(window.location.href.indexOf('StudyMain'));/课程列表页面
//console.log(window.location.href.indexOf('courseware'));/观看视频页面
//课程页面
if(window.location.href.indexOf('StudyMain')>-1){
console.log('课程页面');
setTimeout(collapse(),5000);
return;
}
//视频学习
if(window.location.href.indexOf('courseware')>-1){
console.log('学习页面');
setTimeout(study(),5000);
return;
}
// Your code here...
})();
function collapse(){
//折叠菜单
let tree=document.querySelectorAll('div[class^=tier-tree-one]');
[].slice.call(tree).forEach((value,index)=>{
console.log(index);
console.log(value.getAttribute('class'));
if(value.getAttribute('class').indexOf('open')>-1)
{
value.querySelector('p i').click();
}
});
//展开菜单
let tree2=document.querySelectorAll('div[class^=tier-tree-one] p i');
[].slice.call(tree2).forEach((value,index)=>{value.click()});
//查找未完成
let fonts=document.querySelectorAll('font.c-blue');
for(let ft of fonts){
console.log(ft.parentElement.parentElement.querySelector('span.theme').innerText.includes('学习内容'));
if(ft.parentElement.parentElement.querySelector('span.theme').innerText.includes('学习内容'))
{
//跳转去新课程 font^span^p>span.name>a
ft.parentElement.parentElement.querySelector('span.name a').click();
break;
}
}
}
function study(){
//延缓5秒播放
setTimeout(function(){document.querySelector('div[data-title="点击播放"]').click();},5000);
let t=setInterval(function(){
//暂停继续播放
if(document.querySelector('div[data-title="点击播放"]').getAttribute('style').indexOf('block')>-1){
console.log('暂停了准备继续……');//提示
document.querySelector('div[data-title="点击播放"]').click();}
else
{
console.log('播放中……');//提示
}
//检查播放完毕
let arr=document.querySelector('div#videoPlayer div div:nth-child(3) div:nth-child(13)').innerText.split('/');
if(arr[0].trim()==arr[1].trim() && arr[0].trim()!='00:00:00'){console.log('播放完了');//提示
clearInterval(t);//停止计时
document.querySelector('div#container p a').click();//返回学习
}
else
{
console.log('未播完……');//提示
}
//提示弹窗 单击确定
if(document.querySelector("#panelWindow_confirm_msg").innerText.includes('您')){
console.log('播放提示……');//提示
clearInterval(t);//停止计时
document.querySelector("#panelWindow_confirm > div > p > a.abtn-blue.submit").click();}
},5000)
}