Greasy Fork

Greasy Fork is available in English.

郑州大学远程教育自动播放

郑州大学远程教育1.9

当前为 2022-04-05 提交的版本,查看 最新版本

// ==UserScript==
// @name         郑州大学远程教育自动播放
// @version      1.9
// @description  郑州大学远程教育1.9
// @author       壹局QQ639446649
// @match        http://ols.v.zzu.edu.cn/*
// @icon         https://gitee.com/yjgame-mark/tampermonkey/raw/master/zzdxycjy/logo.png
// @require      http://libs.baidu.com/jquery/2.0.0/jquery.min.js
// @namespace 好好学习天天向上
// ==/UserScript==
(function () {
    setInterval(() => {
        //查看全部课程点播低于10分就进去看视频
        let studyList = $('.dibble_head_ul__3uHKU li');
        if (studyList.length != 0) {
            for (let index = 0; index < studyList.length; index++) {
                const study = studyList[index];
                let studyStateEle = $(study).find('.curriculumCard_study__3e97x');
                let studyState = $(studyStateEle).text().trim();
                if (studyState == '学习中' || studyState == '未学习') {
                    let scoreEle = $(study).find('.curriculumCard_headP2__2tuF1 span:first span');
                    let lowScore = $(scoreEle).text().split('/')[0];
                    if (Number(lowScore) < 10) {
                        $(study).children().click();
                        break;
                    }
                } else {
                    continue;
                }
            }
        }
        //展开所有课程目录
        let couresListTableEles = $('.ant-tree-switcher.ant-tree-switcher_close');
        if (couresListTableEles.length > 0) {
            couresListTableEles.click();
        }
        //调整视频静音及倍速
        let video = $('video');
        if (video.length === 1) {
            video[0].muted = true;
            if (video[0].paused) {
                video[0].play();
            }
            let current = $(".current-time");
            let duration = $(".duration");
            if (current.length > 0) {
                let nowArr = current.text().split(":");
                let endArr = duration.text().split(":");
                let now, end;
                if (nowArr.length == 3) {
                    now = Number(nowArr[0]) * 3600 + Number(nowArr[1]) * 60;
                    // console.log('时now', now);
                } else {
                    now = Number(nowArr[0]) * 60 + Number(nowArr[1]);
                    // console.log('分now', now);
                }
                if (endArr.length == 3) {
                    end = Number(endArr[0]) * 3600 + Number(endArr[1]) * 60;
                    // console.log('时end', end);
                } else {
                    end = Number(endArr[0]) * 60 + Number(endArr[1]);
                    // console.log('分end', end);
                }
                if (parseInt(now / end * 10) >= 9) {
                    window.location.href = "http://ols.v.zzu.edu.cn/xsd/#/index/dibble";
                }
            }
        };
        //判断video不存在或者播放完毕
        if (video.length == 0) {
            //判断未完成或者不到100%就播放
            if (couresListTableEles.length == 0) {
                let couresliEles = $('.video_indexN__1thpU.ant-tree-treenode-switcher-close');
                if (couresliEles.length != 0) {
                    let couresClickEle = $('span:nth-child(2) .ant-tree-title > p');
                    let couresTypeEle = $('.video_start__2y2t5');
                    let couresStateEle = $('.video_state__jhr5B');
                    for (let index = 0; index < couresliEles.length; index++) {
                        const couresType = $(couresliEles[index]).find(couresTypeEle);
                        const couresState = $(couresliEles[index]).find(couresStateEle);
                        if ($(couresType).text() == '视频') {
                            if ($(couresState).length == 0 || $(couresState).text() !== '已完成') {
                                $(couresliEles[index]).find(couresClickEle).click();
                                break;
                            }
                        }
                    }

                }
            }
        }
        //取消设置默认密码
        let quxiao = $('.ant-modal-confirm-btns button:first');
        if (quxiao.length == 1) {
            quxiao.click();
            //跳转课程页
            window.location.href = "http://ols.v.zzu.edu.cn/xsd/#/index/dibble";
        }
        //关闭公告弹窗
        let x = $('.ant-modal-content > button > span');
        if (x.length == 1) {
            x.click();
            //跳转课程页
            window.location.href = "http://ols.v.zzu.edu.cn/xsd/#/index/dibble";
        }
    }, 1000);
})();