使用油猴脚本进行自动观看。

亲测可以4倍速播放,连续播放,自动开始播放,20分钟提示框出来后可以继续自动播放。

4倍速播放,时长计算正常,进度计算正常。

全自动播放,不需要额外干涉,

项目地址:enaeaHelper

简介:

使用教程

1.下载浏览器油猴插件 Tampermonkey

2. 添加新脚本

如何使用

  • 下载浏览器油猴插件 Tampermonkey
  • 添加新脚本
  • 打开油猴插件管理面板
  • 添加仓库内enaeaHelper.js的代码即可

特点

  • 视频默认4倍加速播放,预计节省75%的时间
  • 自动连播当前列表
  • 自动跳转下个列表
  • 真全自动学习(理论上)

已知问题

因为视频加速特点,会导致视频播完时,进度小于100%的情况,不用担心,列表播放一遍后插件会再次检测,对于进度不满的视频再次播放直到100%。


代码:

// ==UserScript==
// @name         enaeaHelper
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  try to take over the world!
// @author       yourself
// @match        https://study.enaea.edu.cn/circleIndexRedirect.do*
// @match        https://study.enaea.edu.cn/viewerforccvideo.do*
// @grant        GM_getValue
// @grant        GM_setValue
// @run-at: document-start
// ==/UserScript==

(function() {
    'use strict';
    var url = window.location.pathname
    var checkBtn = setInterval(clickContinueBtn,3000);
    var checkFinished = setInterval(awaitPageFinishe,5000);
    var checkProgressed = setInterval(checkProgress,3000);

    var speed = 4 // 播放速度,建议在2~4

    if (url == '/circleIndexRedirect.do' && testUrl('action','toNewMyClass') && testUrl('type','course')) {
        sleep(1000).then(() => {
            GM_setValue("baseUrl", window.location.href)
            var l1 = document.getElementsByClassName("progressvalue")
            var l2 = document.getElementsByClassName("golearn  ablesky-colortip  saveStuCourse")
            console.log('进入章节')
            for (var i=0;i<l1.length;i++) {
                if (l1[i].innerText != '100%'){
                    sleep(1000).then(()=>{
                        window.location.href='https://study.enaea.edu.cn' + l2[i].getAttribute("data-vurl")
                    })
                    break
                }
            }
            console.log('运行完成')
        })

    }

    if (url == '/viewerforccvideo.do') {
        sleep(2000).then(()=>{
            // 获取进度
            var l1 = document.getElementsByClassName("cvtb-MCK-CsCt-studyProgress")
            var l2 = document.getElementsByClassName("cvtb-MCK-CsCt-info clearfix")
            var l3 = document.getElementsByClassName("cvtb-MCK-CsCt-title cvtb-text-ellipsis")
            console.log(l1, l2, l3)
            if (l1.length == 0 && l2.length == 0) {
                alert('出错了')
            }
            for(var i=0;i<l1.length;i++){
                if (l1[i].innerText != "100%") {
                    console.log(l3[i])
                    l2[i].click()
                    break
                }
            }
            sleep(300).then(()=>{
                var continueBtn = document.getElementById("ccH5jumpInto")
                if (continueBtn != null) {
                    continueBtn.click()
                }
            })
        })
    }
    function checkProgress(){

        //sleep(2000).then(()=>{
            var current = document.getElementsByClassName("current cvtb-MCK-course-content")

            if (current[0]){
                var currentProgress = current[0].getElementsByClassName("cvtb-MCK-CsCt-studyProgress")
                if (currentProgress[0] && currentProgress[0].innerText == "100%"){
                    // 获取进度
                    var l1 = document.getElementsByClassName("cvtb-MCK-CsCt-studyProgress")
                    var l2 = document.getElementsByClassName("cvtb-MCK-CsCt-info clearfix")
                    var l3 = document.getElementsByClassName("cvtb-MCK-CsCt-title cvtb-text-ellipsis")
                    console.log(l1, l2, l3)
                    if (l1.length == 0 && l2.length == 0) {
                        alert('出错了')
                    }
                    for(var i=0;i<l1.length;i++){
                        if (l1[i].innerText != "100%") {
                            console.log(l3[i])
                            l2[i].click()
                            break
                        }
                    }
                    sleep(300).then(()=>{
                        var continueBtn = document.getElementById("ccH5jumpInto")
                        if (continueBtn != null) {
                            continueBtn.click()
                        }
                    })
                }
            }
        //})
    }

    function testUrl(name,value) {
        var query = window.location.search.substring(1);
       var vars = query.split("&");
       for (var i=0;i<vars.length;i++) {
               var pair = vars[i].split("=");
               if(pair[0] == name){
                if (pair[1] == value){
                    return true
                } else{
                    return false
                };
               }
       }
       return false;
    }

    function clickContinueBtn() {
        if (url == '/viewerforccvideo.do') {
            if ($('video')[0] && $('video')[0].paused){
                $('video')[0].muted = true;
                $('video')[0].playbackRate = parseInt(speed);
                $('video')[0].play()
            }else{
                $('video')[0].playbackRate = parseInt(speed);
            }

            if (document.getElementsByClassName("td-content").length != 0){
                console.log('找到暂停按钮')
                $("button:contains('继续学习')").click();
                $(".dialog-content input").click(); // 问答选项
                $(".dialog-button-container button").click(); // 问答弹窗
            } else {
                console.log('未找到暂停按钮')
            }
        } else {
                console.log('非播放界面,不判断是否完成')
            }
    }

    function awaitPageFinishe(){
        if (url == '/viewerforccvideo.do') {
            var l3 = document.getElementsByClassName("cvtb-MCK-CsCt-studyProgress")
            var count = 0;
            for(var j=0;j<l3.length;j++){
                if (l3[j].innerText != "100%") {
                    count += 1
                }
            }
            if (count == 0) {
                console.log('此章节已完成')
                var baseUrl = GM_getValue('baseUrl','')
                window.location.href=baseUrl
                clearInterval(checkFinished)
                clearInterval(checkBtn)
            } else{
                console.log('章节未完成')
            }
        } else {
            console.log('非播放界面,不判断是否完成')
        }
    }

    function sleep (time) {
        return new Promise((resolve) => setTimeout(resolve, time));
    }
})();

 

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注