华电慕课自动刷

ncepu-mooc-auto-play

华电慕课自动刷
课程可以自动刷,但是题目还是要自己做的哦。
建议有志于搞学术的,好好看看,不要刷,还是挺有用的课程。
本软件仅用于学习研究,请勿用于违法违纪活动。
代码在后文,也可以参见github

功能特点

  1. 播放页面切换到后台也可以继续播放;
  2. 自动选择标清,2倍速播放
  3. 播放完成后自动连播下一节,并可以自动跳过测试题
  4. 题目需要自己做哦!

使用说明

  1. chrome浏览器,安装tampermonkey,具体方式请使用搜索引擎搜索
  2. 点击tampermonkey的图标,添加新脚本
  3. 复制auto-play.js中的js代码,粘贴到编辑框,并CTRL+S保存
  4. 打开任意一个(目前只适用于https://hbdldx.xuetangx.com/地址下的内容)华电网课播放页面(重点:要在播放页面,不是列表页面),即可开始自动播放

TODOs

  1. 代码未经充分测试,匆忙完成,欢迎小伙伴测试并提出问题
  2. 后期如果有时间会进一步添加自动答题等内容
  3. 目前的课时是通过每秒发送一个心跳请求来计算的,后期可以通过分析所有参数,直接发请求,不用打开浏览器了
    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);
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章