- 安装油猴脚本
// ==UserScript==
// @name chinahrt全自动刷课
// @version 0.0.3
// @namespace https://github.com/N3verL4nd/chinahrt
// @description chinahrt全自动刷课,使用见 https://n3verl4nd.blog.csdn.net/article/details/131187984
// @author N3verL4nd
// @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
// @connect gp.chinahrt.com
// @connect videoadmin.chinahrt.com.cn
// @connect videoadmin.chinahrt.com
// @grant GM_xmlhttpRequest
// @license GPL
// ==/UserScript==
// ---------------------------------------------------------------------------
(function() {
'use strict';
// 2分钟刷新下当前页面,防止意外情况
setInterval(function(){
location.reload();
}, 2*60*1000);
// 拦截 Vue 页面 url 变化
setInterval(function(){
if (document.querySelector('#app') != undefined){
if (document.querySelector('#app').__vue__.$router.afterHooks.length == 0) {
document.querySelector('#app').__vue__.$router.afterHooks.push(()=>{location.reload();});
}
}
}, 500);
// 用户凭证
var token = sessionStorage.getItem('jwtToken');
// 固定值
var platformId = sessionStorage.getItem('platformId');
// 我的课程页面
if (window.location.href.indexOf("v_selected_course") > -1) {
sessionStorage.setItem("home", window.location.href + "&jwtToken="+token);
// 培训id
var trainplanId = window.location.href.match(/trainplanId=([^&]*)/)[1];
sessionStorage.setItem("trainplanId", trainplanId);
GM_xmlhttpRequest({
method: "GET",
url: "https://gp.chinahrt.com/gp6/lms/stu/trainplanCourseHandle/selected_course?curPage=1&pageSize=1&learnFinish=0&trainplanId=" + trainplanId + "&platformId=" + platformId,
headers: {
"Hrttoken": token
},
onload: function(response) {
var jsonResult = JSON.parse(response.responseText);
// 所有未完成课程
var courseStudyList = jsonResult.data.courseStudyList;
if (courseStudyList == null || courseStudyList.length == 0) {
return;
}
// 只取一个课程
var courseId = courseStudyList[0].courseId;
sessionStorage.setItem("courseId", courseId);
// 课程详情
GM_xmlhttpRequest({
method: "GET",
url: "https://gp.chinahrt.com/gp6/lms/stu/course/courseDetail?courseId=" + courseId + "&trainplanId=" + trainplanId + "&platformId=" + platformId,
headers: {
"Hrttoken": token
},
onload: function(response) {
var jsonResult = JSON.parse(response.responseText);
// 章节列表
var chapterList = jsonResult.data.course.chapter_list;
var courseName = jsonResult.data.course.name;
if (chapterList == null || chapterList.length == 0) {
console(jsonResult.data.course.name + " 无章节信息");
return;
}
for(var j = 0; j < chapterList.length; j++) {
var sectionList = chapterList[j].section_list;
var chapterName = chapterList[j].name;
if (sectionList == null || sectionList.length == 0) {
continue;
}
for(var k = 0; k < sectionList.length; k++) {
if(sectionList[k].study_status != '已学完') {
var sectionId = sectionList[k].id;
sessionStorage.setItem("sectionId", sectionId);
// 跳转待学习课程章节
window.top.location.href = "https://gp.chinahrt.com/index.html#/v_video?platformId=" + platformId + "&trainplanId=" + trainplanId + "&courseId=" + courseId + "§ionId=" + sectionId;
return;
}
}
}
}
});
}
});
}
if (window.location.href.indexOf("/v_video") > -1) {
var checkJob = setInterval(() => {
// 检测当前学习章节状态
var courseId = sessionStorage.getItem('courseId');
var trainplanId = sessionStorage.getItem('trainplanId');
var platformId = sessionStorage.getItem('platformId');
var sectionId = sessionStorage.getItem('sectionId');
var home = sessionStorage.getItem('home');
GM_xmlhttpRequest({
method: "GET",
url: "https://gp.chinahrt.com/gp6/lms/stu/course/courseDetail?courseId=" + courseId + "&trainplanId=" + trainplanId + "&platformId=" + platformId,
headers: {
"Hrttoken": token
},
onload: function(response) {
var jsonResult = JSON.parse(response.responseText);
console.log(jsonResult);
// 章节列表
var chapterList = jsonResult.data.course.chapter_list;
var courseName = jsonResult.data.course.name;
if (chapterList == null || chapterList.length == 0) {
console(jsonResult.data.course.name + " 无章节信息");
return;
}
for(var j = 0; j < chapterList.length; j++) {
var sectionList = chapterList[j].section_list;
var chapterName = chapterList[j].name;
if (sectionList == null || sectionList.length == 0) {
continue;
}
for(var k = 0; k < sectionList.length; k++) {
if(sectionList[k].id == sectionId) {
if (sectionList[k].study_status == '已学完') {
clearInterval(checkJob);
// 调回我的课程页面
window.location.href = home;
} else {
console.log("当前课程章节学习进度: " + sectionList[k].studyTimeStr + ", 总进度: " + sectionList[k].total_time_str);
return;
}
}
}
}
}
});
}, 5000);
}
// 视频播放初始化
function init() {
// 移除讨厌的事件
removePauseBlur();
// 总是显示播放进度
player.changeControlBarShow(true);
// 静音
player.videoMute();
// 自动播放
player.videoPlay();
}
// 课程播放页面
if (window.location.href.indexOf("/videoPlay/play") > -1) {
var tmp = setInterval(function () {
if (player != undefined) {
player.addListener('loadedmetadata', init);
init();
clearInterval(tmp);
}
}, 500);
}
})();
- 选课
- 进入我的课程页面

脚本会选择未完成课程,自动学习。