// ==UserScript== // @name 网上学院-学时助手2.0 // @namespace none // @version 0.4 // @description 学时刷不完? 使用Edge/Firefox 安装TamperMonkey扩展,使用本插件即可。 // @author WenYichong //首页 // @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 // @downloadURL none // ==/UserScript== (function () { var currentURL = window.location.href; // 获取当前网页地址 console.log('当前网页',currentURL); console.log(new Date()) window.setTimeout(()=>{ if( currentURL.endsWith('learner/home')){ console.log('首页'); // window.location.href="http://wsxy.chinaunicom.cn/learner/subject/49659088/detail"; } else if( currentURL.endsWith('/detail') ){ console.log('列表'); seleCourse(); // 选择课程 } else if( currentURL.endsWith('learner/subject')){ console.log('专题栏'); // window.open('http://wsxy.chinaunicom.cn/learner/subject/49659088/detail','_self'); //政企专区 window.open('http://wsxy.chinaunicom.cn/learner/subject/49668818/detail','_self'); //"数字菁英”培训专区 } else if( currentURL.endsWith('course/detail')){ console.log('详情'); detailOp(); } else if( currentURL.endsWith('play/course')){ 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(){ } })();