Greasy Fork

奥鹏教师教育网刷课2021

奥鹏教师教育网

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

// ==UserScript==
// @name         奥鹏教师教育网刷课2021
// @version      1.0
// @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 courseLength,temp,isFinish = 0
        var courseList
        courseList = document.getElementsByClassName("er")[0]
        courseLength = courseList.getElementsByClassName("clearfix").length
        //遍历所有课程,找到第一门未完成课程并进入
        for(temp=0;temp<courseLength;temp++){
            if(courseList.getElementsByClassName("clearfix")[temp].innerHTML.indexOf("a-bg-tip-orange")!=-1){
                courseList.getElementsByClassName("clearfix")[temp].getElementsByTagName("a")[0].click()
                isFinish = 1
                break;
            }
        }

        if(isFinish == 0){
            courseList = document.getElementsByClassName("er")[1]
            courseLength = courseList.getElementsByClassName("clearfix").length
            //遍历所有课程,找到第一门未完成课程并进入
            for(temp=0;temp<courseLength;temp++){
                if(courseList.getElementsByClassName("clearfix")[temp].innerHTML.indexOf("a-bg-tip-orange")!=-1){
                    courseList.getElementsByClassName("clearfix")[temp].getElementsByTagName("a")[0].click()
                    isFinish = 1
                    break;
                }
            }
        }

        //等待课程详情加载完成,自动点击学习按钮
        if(isFinish == 1){
            setTimeout(function(){
                window.location.href = document.getElementsByClassName("btnstyle sure btn-orange btn-Study")[0].href
            },1500)
        }
    }

    if(href.indexOf("StepLearn/StepLearn")!=-1){
        //学完提醒
        var timeText
        var videoFlag = 0
        function isTimeOut(){
            if(timeText == document.getElementById("learnTime").innerHTML){
                //弹出题目后
                location.reload(true);
            }
            else{
                timeText = document.getElementById("learnTime").innerHTML
                if(timeText != "0/0"){
                    document.getElementsByClassName("Left title")[0].innerHTML = timeText//.split("/")[0].split("分")[0] + timeText.split("/")[1].split("分")[0]//timeText
                    if(timeText.split("/")[0].split("分")[0] == timeText.split("/")[1].split("分")[0]){
                        //时间条满后
                        if(videoFlag){
                            document.getElementById("exit").click()
                        }
                    }
                }
            }
            setTimeout(function(){isTimeOut()},2000)
        }


        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"){
                    videoList[temp].click()
                    return
                }else if(videoList[temp].className.indexOf("go") != -1 || videoList[temp].className == "go active" || videoList[temp].className == "listdot listdot-y"|| videoList[temp].className == "active go"|| videoList[temp].className == "default go"){
                    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(){
            if(!videoFlag){
                setTimeout(function(){isVideoFinish()},0)
                setTimeout(function(){setVideoplay()},4000)
            }
        }
        setTimeout(function(){isTimeOut()},2000)
    }
})();