// ==UserScript== // @name chinahrt继续教育;chinahrt全自动刷课;解除系统限制; // @version 3.0.1 // @namespace https://github.com/yikuaibaiban/chinahrt // @description 【❤全自动刷课❤】功能可自由配置,只需将视频添加到播放列表,后续刷课由系统自动完成;使用教程:https://www.cnblogs.com/ykbb/p/16695563.html // @author yikuaibaiban;https://www.cnblogs.com/ykbb/;https://github.com/yikuaibaiban // @icon data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAArFJREFUWEftlttPE0EUxr+9ddtdYOXSSmmlFFoasSFemmg0qYkIMfGF/9J/wTeN0cSYGBHEBBIoLSIU0VrKpe1eagaySWVmutu+GJPO4+5cfvOdc745wkGl3sI/HEIf4L9ToHrqoHLi4LTRgmm1IAhAMCDgmi4ibEgQhe4SyncOFA9tFMoWaucO9wRJFDAZlpCeUKAq/kA8AY7PHKwWmqic+i8WRRaQTciIj8qeFB0Bjo4dvN9ooOX/7L8OnLshYybaWQouALn5m/XeD3dJ5qcCSEQkrhJcgLfrdabshV8mvtdsPEoEPeV1JzzOqhjSROZ8JsBO2cJa0WQueLFSQ6lqYWpYQT4ZQnSQfzt3g+iwhFw64B/g9VqDm+0uANlNkYB8UkMupnqqkc+qMBgqUAqQOiex5412AHdOJhzAUlqDpvBNIBOXMTtBJyQF0El+ciALgHwfUEUspjTMjrGzPmKIuJ+hlaIA1ksmtg+srhRon7wwE0IuTieoHhTwZJ7+TgGsbDexe2T3DJAdV/E8o1HriTMu3QlR3ymAz4UmSj96A1AkActzOqZH6DD4BtjYM7G5130IYkMynmV0jHHqfXRQxMObPnKg/NvGh81mVyG4HQ1gcVYH22out5oel3Fr0kcVOC3g5cdz2JxH72oVPE1ruDfh7QMPMirCBo3IdMIvRfPi6WUNF2BMl0Aynjii1yAGRIyINZgADRN4tVa/aDiujnfFOg5PbCykNAyp/roPYsPEjn0DkInfflr4tMV+D7xu3P4/eV1GNsFXqWM/sLVv4usuvyK8QGIjEu6m2I+Qu9azIyKt2OoOvyp4EF439w1AJpLmhHjDfoVvUO6GJOHSMZkb86vAngq0L6ieOSA+UalddsWWfZmkA0ERhi4iYkjMUusUqq4AvGLey/8+QF+BP0npcPDdfTv7AAAAAElFTkSuQmCC // @match http://*.chinahrt.com/* // @match https://*.chinahrt.com/* // @match http://videoadmin.chinahrt.com.cn/videoPlay/play* // @match http://videoadmin.chinahrt.com/videoPlay/play* // @match https://videoadmin.chinahrt.com.cn/videoPlay/play* // @match https://videoadmin.chinahrt.com/videoPlay/play* // // @grant unsafeWindow // @grant GM_setValue // @grant GM_getValue // @grant GM_addValueChangeListener // @grant GM_notification // // @license GPL // @downloadURL none // ==/UserScript== // 课程预览页面 const COURSE_PREVIEW = 0; // 课程播放页面 const COURSE_PALY = 1; // 视频播放页面 const VIDEO_PALY = 2; // VUE课程预览页面 const VUE_COURSE_PREVIEW = 3; // 未知页面 const UNKOWN_PAGE = 9999; // 课程存储关键字 const COURSES = "courses"; // 自动播放 const AUTOPLAY = "autoPlay"; // 静音 const MUTE = "mute"; // 拖动 const DRAG = "drag"; // 播放速度 const SPEED = "speed"; // 获取自动播放 function getAutoPlay() { return GM_getValue(AUTOPLAY, true); } // 获取静音 function getMute() { return GM_getValue(MUTE, true); } // 获取拖动 function getDrag() { return GM_getValue(DRAG, 5); } // 获取播放速度 function getSpeed() { return GM_getValue(SPEED, 1); } // 获取播放列表 function getCourses() { var value = GM_getValue(COURSES, []); if (Array.isArray(value)) { return value; } return []; } // 添加到播放列表 function addCourse(element) { if (!element.title || !element.url) { console.error(element); alert("添加失败,缺少必要参数"); return false; } var oldValue = getCourses(); if (oldValue.findIndex(value => value.url == element.url) > -1) { alert("已经存在播放列表中"); return false; } oldValue.push({ title: element.title, url: element.url }); GM_setValue(COURSES, oldValue); return true; } // 从播放列表移除 function removeCourse(index) { var courses = getCourses(); if (Number.isNaN(index)) { for (let i = courses.length; i >= 0; i--) { const element = courses[i]; // 正则提取 href 中 sectionId courseId trainplanId var jsonHref = element.url; var jsonSectionId = jsonHref.match(/sectionId=([^&]*)/)[1]; var jsonCourseId = jsonHref.match(/courseId=([^&]*)/)[1]; var jsonTrainplanId = jsonHref.match(/trainplanId=([^&]*)/)[1]; // 正则提取 window.location.href 中 sectionId courseId trainplanId var href = window.location.href; var sectionId = href.match(/sectionId=([^&]*)/)[1]; var courseId = href.match(/courseId=([^&]*)/)[1]; var trainplanId = href.match(/trainplanId=([^&]*)/)[1]; if (jsonCourseId == courseId && jsonSectionId == sectionId && jsonTrainplanId == trainplanId) { courses.splice(i, 1); } } } else { courses.splice(index, 1); } GM_setValue(COURSES, courses); } // 生成可以添加到播放列表的容器 function createCanPlayList() { // 生成容器 var playListBox = $("
", { id: "canPlayBox", css: { width: "300px", height: "500px", position: "fixed", top: "100px", background: "rgba(255,255,255,1)", right: "20px", border: "1px solid #c1c1c1" } }); var status = $("
", { text: "获取中...", css: { height: "30px", "border-bottom": "1px solid", "text-align": "center", "line-height": "30px", "color": "#4bccf2", "font-weight": "bold" }, click: function () { playListBox.trigger("clear"); if (getPageNumber() == VUE_COURSE_PREVIEW) { vue_findCourses(playListBox); } else { findCourses(playListBox); } } }); status.appendTo(playListBox); var listBox = $("
", { css: { height: "470px", "overflow-y": "auto" } }).appendTo(playListBox); playListBox.on("clear", function () { status.text("获取中..."); listBox.empty(); }); // 添加绑定事件 playListBox.on("bind", function (e, data) { if (status.text() == "获取中...") { status.text("点击刷新"); } var box = $("
", { css: { "border-bottom": "1px solid #c1c1c1", "padding": "8px", "line-height": "150%", "border-bottom": "1px solid #c1c1c1", "margin-bottom": "3px" } }); var ptitle = $("

", { text: data.title, title: data.title, css: { "font-size": "13px", "white-space": "nowrap", "overflow": "hidden", "text-overflow": "ellipsis", } }); ptitle.appendTo(box); var pstatus = $("

", { text: "学习状态: " + data.status, title: "学习状态: " + data.status, css: { "font-size": "12px", "white-space": "nowrap", "overflow": "hidden", "text-overflow": "ellipsis", "color": "#c1c1c1" } }); pstatus.appendTo(box); var disabled = getCourses().findIndex(value => value.url == data.url) > -1; var button = $("