ncepu-mooc-auto-play
华电慕课自动刷
课程可以自动刷,但是题目还是要自己做的哦。
建议有志于搞学术的,好好看看,不要刷,还是挺有用的课程。
本软件仅用于学习研究,请勿用于违法违纪活动。
代码在后文,也可以参见github
功能特点
- 播放页面切换到后台也可以继续播放;
- 自动选择标清,2倍速播放
- 播放完成后自动连播下一节,并可以自动跳过测试题
- 题目需要自己做哦!
使用说明
- chrome浏览器,安装tampermonkey,具体方式请使用搜索引擎搜索
- 点击tampermonkey的图标,添加新脚本
- 复制auto-play.js中的js代码,粘贴到编辑框,并CTRL+S保存
- 打开任意一个(目前只适用于https://hbdldx.xuetangx.com/地址下的内容)华电网课播放页面(重点:要在播放页面,不是列表页面),即可开始自动播放
TODOs
- 代码未经充分测试,匆忙完成,欢迎小伙伴测试并提出问题
- 后期如果有时间会进一步添加自动答题等内容
- 目前的课时是通过每秒发送一个心跳请求来计算的,后期可以通过分析所有参数,直接发请求,不用打开浏览器了
2019-12-17更新:修正章节完成后不能自动续播的问题。
// ==UserScript==
// @name 华电慕课自动刷
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @require http://code.jquery.com/jquery-1.11.0.min.js
// @include https://hbdldx.xuetangx.com/*
// ==/UserScript==
window.counter = 0;
window.currentTime = 0;
window.setInterval(function () {
let current_video = $('video')[0];
if(!current_video){
return;
}
if (current_video.ended) {
let next = null;
let $pre_section = $(".section-video-name.video-active").parents('.tree-section-item').next();
$pre_section.click();
let $next_section = $pre_section.find('.tree-section-item__name:first');
if ($next_section.find('i').length) {
$next_section.find('i.el-icon-arrow-down').click();
next = $next_section.next().find('.element-wrap');
}
if (!next) {
// 展开章节
let $chapter = $(".section-video-name.video-active").parents('.tree-chapter-item').next();
if (!($chapter.find('.tree-section-item__name:first').length)) {
$chapter.find('.tree-chapter-item__name:first').click();
}
// 获取第一节
let $section = $chapter.find('.tree-section-item__name:first');
if (!($section.next().find('.section-video-name').length)) {
$section.click();
}
//获取视频按钮
next = $section.next().find('.section-video-name span:last');
}
next.click();
} else {
$('li:contains("标清")').click();
let $btn_speed = $('.xt_video_player_common_value:first').next();
$btn_speed.find('li[data-speed=2]').click()
let playPromise = current_video.play()
if (playPromise !== undefined) {
playPromise.then(() => {
current_video.play();
}).catch(()=> {
});
}
if(current_video.currentTime!=0 && window.currentTime==current_video.currentTime){
window.counter+=1;
if(window.counter>=5){
window.counter = 0;
window.location.reload(true)
}
}else{
window.currentTime = current_video.currentTime;
window.counter = 0;
}
}
}, 1000);