研修网学习脚本【XCC版】
生活随笔
收集整理的這篇文章主要介紹了
研修网学习脚本【XCC版】
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
發(fā)布:https://codechina.csdn.net/-/snippets/1071/raw/master/xcc-yanxiu.js
// ==UserScript== // @name 研修網(wǎng)學習腳本【XCC版】 // @namespace https://greasyfork.org/ // @version 0.1 // @description 研修網(wǎng)學習腳本【XCC版】 // @author FRLH // @match https://ipx.yanxiu.com/train/* // @match https://ipx.yanxiu.com/grain/course/* // @grant none // ==/UserScript==window.AutoRun = {add: playList => {let playListCache = getPlayListCache();localStorage.setItem("playListCache", JSON.stringify(playListCache.concat(playList)));},reset: () => {localStorage.removeItem("playIndexCache");localStorage.removeItem("playListCache");} }function getPlayIndexCache() {let playIndexCache = localStorage.getItem("playIndexCache");return playIndexCache == null ? 0 : playIndexCache; }function getPlayListCache() {let playListCache = localStorage.getItem("playListCache");if (playListCache == null) {playListCache = [];} else {playListCache = JSON.parse(playListCache);}return playListCache; }function getClassHours() {let hasClasshours = document.querySelector(".score").innerText;let classhours = document.querySelector(".total-score").innerText;classhours = classhours.substr(0, classhours.length - 2);return classhours - hasClasshours; }function playCourses(classHours = getClassHours()) {let projectId = getQueryString("projectId");let toolId = getQueryString("toolId");let role = getQueryString("role");let playWindow = null;let playClassHours = 0;let playIndex = getPlayIndexCache();let timer = setInterval(function () {let playList = getPlayListCache();if (playIndex < playList.length && (playWindow == null || playWindow.closed)) {if (playWindow != null) {playClassHours += parseFloat(playList[playIndex - 1].classHours);localStorage.setItem("playIndexCache", playIndex - 1);}if (playClassHours >= classHours) {console.info(`學習完畢:已學習${playClassHours}/${classHours}課時`);clearInterval(timer);return;}let course = playList[playIndex++];playWindow = window.open();playWindow.location = `https://ipx.yanxiu.com/grain/course/${course.id}/detail?projectId=${projectId}&toolId=${toolId}&courseSourceId=${course.courseSourceId}&role=${role}`;console.info(`正在播放:【${playIndex}/${playList.length}】【${playClassHours}/${classHours}】${course.courseName},時長:${course.noStudyTime / 60}分鐘,課時:${course.classHours}`);} else if (playIndex >= playList.length) {console.info("請?zhí)砑诱n程:AutoRun.add(課程列表)");}}, 10000); }function playCourse() {//處理播放器事件if (document.querySelector("video")) {let playerH5 = document.querySelector("video");playerH5.volume = 0; //不想聽聲音if (playerH5.paused) {playerH5.play(); //不要暫停,播下去}} else {// 如果第一個課件不是視頻,則點擊第一個視頻document.querySelector(".res-relatedCourse").parentElement.childNodes[2].click();}//處理各種突發(fā)事件if (document.querySelector("div.alarmClock-wrapper").style.display == "") {document.querySelector("div.alarmClock-wrapper").click();console.log("點繼續(xù)看課");}if (document.querySelector("div.scoring-wrapper").style.display == "") {document.querySelector(".scoring-wrapper .rating").lastElementChild.click();document.querySelector('div.commit > button.ivu-btn').click();console.log("給老師評價");}if (document.querySelector("button.ivu-btn.ivu-btn-text")) {document.querySelector("button.ivu-btn.ivu-btn-text").click();console.log("打開了其他播放頁面,即將關(guān)閉本頁面");}if (document.querySelector(".state > span").innerText.match(/您已完成看課總時長/)) {console.log("課時已達成,即將關(guān)閉頁面");window.close();}if (document.querySelector("div.ended-mask").style.display == "") {if (document.querySelector("p.next")) {document.querySelector("p.next").click();console.log("一個看完,看下一個內(nèi)容");} else {console.log("播放完畢,即將關(guān)閉頁面");window.close();}}}function start() {//判斷是哪個頁面if (location.pathname === "/train/guide/course/list") {console.log("進入課程列表頁面");playCourses();} else if (location.pathname.match(/\/grain\/course\/\d*\/detail/)) {console.log("進入課程視頻頁面");setInterval(playCourse, 5000);} else {console.log("未知頁面");} }function getQueryString(name) {var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");var r = window.location.search.substr(1).match(reg);if (r != null) return unescape(r[2]);return null; }(function () {console.log("正在加載腳本");setTimeout(start, 10000); })();總結(jié)
以上是生活随笔為你收集整理的研修网学习脚本【XCC版】的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 解决Shape数据形状数与表记录数不一致
- 下一篇: python刷课系统教师_让教师只想刷课