華電慕課自動刷

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);
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章