Greasy Fork

奥鹏教师教育网刷课2021

奥鹏教师教育网自动学习

目前为 2021-01-19 提交的版本。查看 最新版本

// ==UserScript==
// @name         奥鹏教师教育网刷课2021
// @version      1.11
// @description  奥鹏教师教育网自动学习
// @author       why3303

// @match        *://*.ourteacher.com.cn/*
// @grant        none
// @namespace https://greasyfork.org/users/728857
// ==/UserScript==

(function() {
    'use strict';
    var href = location.href
    var vlocalUsername
    var vlocalPassport

    if(document.cookie.indexOf("localUsername") == -1){
        vlocalUsername=prompt("请输入奥鹏账号(只有一次机会不要输错了)","")
        vlocalPassport=prompt("请输入密码(只有一次机会不要输错了)","")
        document.cookie = "localUsername="+vlocalUsername+";expires=Thu, 18 Dec 2043 12:00:00 GMT;domain=.ourteacher.com.cn;path=/"
        document.cookie = "localPassport="+vlocalPassport+";expires=Thu, 18 Dec 2043 12:00:00 GMT;domain=.ourteacher.com.cn;path=/"
    }else{
        var tempStr = document.cookie;
        vlocalUsername=tempStr.split("localUsername=")[1].split(";")[0];
        vlocalPassport=tempStr.split("localPassport=")[1].split(";")[0];
    }

    if(href == "http://www.ourteacher.com.cn/" || href == "https://www.ourteacher.com.cn/"){
        document.getElementById("userName").value = vlocalUsername
        document.getElementById("passWord").value = vlocalPassport
        document.getElementsByClassName("btn btn-success")[0].click();
    }

    if(href.indexOf("passport.ourteacher.com.cn/Account/LoginIndex") != -1){
        document.getElementById("aw-login-user-name").value = vlocalUsername
        document.getElementById("aw-login-user-password").value = vlocalPassport
        document.getElementById("login_submit").click();
    }

    if(href.indexOf("WorkRoom/Index") != -1 || href == "https://activity.ourteacher.com.cn/"){
        setTimeout(function(){
            window.location.href = document.getElementById("goLearn").href
        },2000)
    }

    if(href.indexOf("Activity/Index?ActivitiesID=")!=-1){
        var temp1,temp2
        var courseList

        var chapterList = document.getElementsByClassName("news-list news-list1")[0].children

        for(temp1 = 0; temp1 < chapterList.length; temp1++){
            //遍历所有课程,找到第一门未完成课程并进入
            courseList = chapterList[temp1].getElementsByClassName("er")[0].getElementsByClassName("clearfix")
            for(temp2=0;temp2<courseList.length;temp2++){
                if(courseList[temp2].innerHTML.indexOf("a-bg-tip-orange")!=-1){
                    courseList[temp2].getElementsByTagName("a")[0].click()
                    setTimeout(function(){
                        window.location.href = document.getElementsByClassName("btnstyle sure btn-orange btn-Study")[0].href
                    },1500)//等待课程详情加载完成,自动点击学习按钮
                    return;
                }
            }
        }



    }

    if(href.indexOf("StepLearn/StepLearn")!=-1){
        //学完提醒
        var timeText
        var videoFlag = 0




        function isTimeOut(){
            if(timeText == document.getElementById("learnTime").innerHTML && timeText != "0分0秒"){
                //弹出题目后
                location.reload(true);
            }
            else{
                timeText = document.getElementById("learnTime").innerHTML
                if(timeText != "0/0"){
                    document.getElementsByClassName("Left title")[0].innerHTML = timeText
                    if(timeText.split("/")[0].split("分")[0] == timeText.split("/")[1].split("分")[0]){
                        //时间条满后
                        if(videoFlag){
                            document.getElementById("exit").click()//看完一课后退出重新登录,防止超时掉线
                        }
                    }
                }
            }
        }


        function isVideoFinish(){
            var videoList = document.getElementsByClassName("a-border  CourseLeftmenu")[0].getElementsByTagName("a")
            var temp;
            for(temp = 0;temp < videoList.length;temp++){
                if(videoList[temp].className == "listdot" || videoList[temp].className == "default"){//此处为未看视频标签的class标识
                    videoList[temp].click()
                    return
                }else if(videoList[temp].className.indexOf("go") != -1 || videoList[temp].className == "listdot listdot-y"){//此处为正在观看视频标签的class标识
                    var videoObj = document.getElementsByName("rightFrame")[0].contentWindow.document.getElementsByTagName('video')[0]
                    videoObj.autoplay = true
                    videoObj.play()
                    videoObj.currentTime = videoObj.duration
                    return
                }
            }
            videoFlag = 1
        }


        function setVideoplay(){//该函数用来定时启动isVideoFinish(),防止该函数递归定时启动时出错卡死
            if(!videoFlag){
                setTimeout(function(){isVideoFinish()},0)
                setTimeout(function(){setVideoplay()},4000)
            }
        }

        //测试代码

        //测试代码结束
        setTimeout(function(){setVideoplay();},4000)
        setInterval(function(){isTimeOut();},2000)
        setTimeout(function(){location.reload(true);},630000)//视频页面每十分半刷新一次,防止掉线
    }
})();