zjooc在浙学刷课

网页端/安卓端 一键刷课

目前为 2021-12-05 提交的版本。查看 最新版本

// ==UserScript==
// @name         zjooc在浙学刷课
// @namespace    GAEE
// @version      1.0.0
// @description  网页端/安卓端 一键刷课
// @match        https://www.zjooc.cn/*
// @grant        unsafeWindow
// @license      none
// ==/UserScript==
let APP_Version = "1.0.0";

//
// 由于网页脚本维护不便,无法及时更新请见谅。
// 如需获得更好体验请移步介绍页下载安卓脚本
//

var startTime = 5000;   //刷课间隔时间 //若超过该时间页面还未加载则自动跳过
var IntervalTime = 2000;//监测时长
var Video_muted = true; //开启静音
var Video_speed = 4;    //倍速设置 最大16

(function() {
    'use strict';
    const urls = {'course':'https://www.zjooc.cn/ucenter/student/course/study/[A-Za-z0-9]+/plan/detail/[A-Za-z0-9]+'};

    var ListStudy_main = [];
    var ListStudy_view = [];

    var ListStudy_main_now;
    var ListStudy_view_now;

    var Interval;


    var url = unsafeWindow.location.href;
    var href = new RegExp(urls.course);
    console.log(href.test(url));
    if(href.test(url)){
        unsafeWindow.setTimeout(function(){
            console.log("============ 开始执行脚本 =================");
            GET_MAIN_LIST();
            GET_VIEW_LIST();
            console.log(ListStudy_main);
            console.log(ListStudy_view);
            if(ListStudy_main == ""){
                console.log("全部完成");
            }else{
                ListStudy_main_now = ListStudy_main[0];
                if(ListStudy_view == ""){
                    console.log("当前小节已完成");
                    unsafeWindow.setTimeout(NEXT_MAIN,startTime);
                }else{
                    ListStudy_view_now = ListStudy_view[0];
                    unsafeWindow.setTimeout(NEXT_VIEW,startTime);
                }
            }
        },startTime);
    }

    function AUTO_COURSE(){
        if(Interval){
            unsafeWindow.clearInterval(Interval);
        }
        console.log("============ 开始刷课 ==============");
        var document_ok = document.querySelector('.contain-bottom').querySelector('button.el-button.el-button--default');
        console.log(document_ok);
        if(document_ok){
            document_ok.click();
        }
        var video = document.querySelector('video');
        console.log(video);
        if(video){
            video.muted = Video_muted;
            video.playbackRate = Video_speed;
            video.play();

            Interval = unsafeWindow.setInterval(VIDEO_OK,IntervalTime);
        }else{
            unsafeWindow.setTimeout(NEXT_VIEW,startTime);
        }
    }

    function VIDEO_OK(){
        try{
            var video=document.querySelector('video');
            var bar = video.parentNode.children[2];
            var processBar = bar.children[7];
            var times = processBar.innerText.split('/');
            var now = times[0].trim();
            var end = times[1].trim();
            console.log(times);
            if(now==end){
                if(Interval){
                    unsafeWindow.clearInterval(Interval);
                }
                unsafeWindow.setTimeout(NEXT_VIEW,startTime);
            }
        }catch(err) {
            console.log(err);
        }
    }

    function NEXT_MAIN(){
        if(ListStudy_main_now.nextSibling == null){
            console.log("全部完成");
        }else{
            ListStudy_main_now = ListStudy_main_now.nextSibling;
            ListStudy_main_now.click();
            GET_VIEW_LIST();
            if(ListStudy_view == ""){
                console.log("当前小节已完成");
                unsafeWindow.setTimeout(NEXT_MAIN,startTime);
            }else{
                unsafeWindow.setTimeout(AUTO_COURSE,startTime);
            }
        }
    }

    function NEXT_VIEW(){
        if(ListStudy_view_now.nextSibling == null){
            console.log("当前小节已完成");
            unsafeWindow.setTimeout(NEXT_MAIN,startTime);
        }else{
            ListStudy_view_now = ListStudy_view_now.nextSibling;
            ListStudy_view_now.click();
            unsafeWindow.setTimeout(AUTO_COURSE,startTime);
        }
    }

    function GET_MAIN_LIST(){
        ListStudy_main = [];
        //get main list
        var main_list = document.querySelector('.base-asider ul[role="menubar"]');
        for(var a=0; a<main_list.childElementCount; a++){
            var sec_list = main_list.children[a].children[1];
            for(var b=0; b<sec_list.childElementCount; b++){
                var _e = sec_list.children[b];
                if(_e.getAttribute('tabindex')=='0')//-1 unfinish 0 finish
                {
                    console.log("finished");
                }else{
                    console.log(_e.innerText);
                    ListStudy_main.push(_e);
                }
            }
        }
        //end
    }

    function GET_VIEW_LIST(){
        ListStudy_view = [];
        var list = document.querySelector('.plan-detailvideo div[role="tablist"]');
        for(var i=0; i<list.childElementCount; i++){
            var e = list.children[i];
            if(e.getAttribute('tabindex')=='0')//0 ok -1 unfinish
            {
                console.log("finished");
            }else{
                console.log(e.innerText);
                ListStudy_view.push(e);
            }
        }
    }

})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址