// ==UserScript== // @name 网上学院-学时助手 // @namespace none // @version 2.0 // @description 学时刷不完? 使用Edge/Firefox 安装TamperMonkey扩展,使用本插件即可。本插件是按专区刷课的,需要刷其他专区的把shuakeURL 参数改成要刷的专区网址。 // @author WenYichong // @license MIT // @match http://wsxy.chinaunicom.cn/learner/* // @grant none // @run-at document-end // @require https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js // @downloadURL none // ==/UserScript== //替换成要刷的专区网址 let shuakeURL = "http://wsxy.chinaunicom.cn/learner/subject/49659088/detail"; //政企专区 //let shuakeURL = "http://wsxy.chinaunicom.cn/learner/subject/49668818/detail"; //"数字菁英”培训专区 /** * 课程列表 选择课程 */ function seleCourse() { document.querySelector('body > spk-root > spk-home > div > nz-spin > div.ant-spin-container > spk-special-area-detail > div > div:nth-child(3) > spk-area-all-course > div > div.type > div.right > span:nth-child(7)').click()//未完成 setTimeout(() => { document.getElementsByClassName('single-course')[0].getElementsByTagName('a')[0].click() //选择第一个课程进入 }, 1000) } /* 详情页面操作 */ function detailOp() { setTimeout(() => { document.getElementsByClassName('course-button')[0].click() //开始学习 }, 1000) setTimeout(() => { palylOp(); }, 5000) }; /* 播放页面操作 */ function palylOp() { var items = document.getElementsByClassName('title') var num = items.length; console.log('视频数', num); let vdoc = document.getElementsByTagName('iframe')[0].contentDocument //播放器iframe let vP = vdoc.getElementsByTagName('video')[0] //播放器 vP.muted = true //静音 vP.play() let nowTime = 0 setInterval(() => { vP.playbackRate = 3 //三倍速 let nowItem = document.getElementsByClassName('course-single clearfix active-s')[0] if (nowItem.getElementsByClassName('title')[0].textContent === items[num - 1].textContent) { //播放最后一个视频; if (vP.ended || vP.duration === vP.currentTime) { window.open(shuakeURL, '_self'); } } //时间刷完,或者未走动 if (vP.currentTime === nowTime) { window.open(shuakeURL, '_self'); } nowTime = vP.currentTime //记录当前播放时间,如果10秒钟之后没有改变,则视频播放完或者卡死 console.log('进度:', nowItem.getElementsByClassName('title')[0].textContent, '-->', vP.currentTime / 60, '/', vP.duration) document.getElementsByClassName('save-logout-box ant-btn ant-btn-primary')[0].click()//保存学习记录 }, 10000); } (function () { var currentURL = window.location.href; // 获取当前网页地址 console.log('当前网页', currentURL); console.log(new Date()) window.onload = function () { if (currentURL.endsWith('learner/home')) { console.log('首页'); } else if (currentURL.endsWith('/detail')) { console.log('列表'); setTimeout(() => { seleCourse(); // 选择课程 }, 1000) } else if (currentURL.endsWith('learner/subject')) { console.log('专题栏'); window.open(shuakeURL, '_self'); //培训专区 } else if (currentURL.indexOf('course/detail') > 0) { console.log('详情'); detailOp(); } else if (currentURL.endsWith('play/course')) { console.log('播放'); palylOp(); } }; window.setTimeout(() => { }, 1500); })();