wlxx

网络学习代码

目前为 2022-08-02 提交的版本。查看 最新版本

此脚本不应直接安装,它是一个供其他脚本使用的外部库。如果您需要使用该库,请在脚本元属性加入:// @require https://update.cn-greasyfork.org/scripts/443181/1076859/wlxx.js

function func() {
    try {
        var i=0;var x1, t1;
        var zf1=24;//看课总分
        var zf2=6;//能力点总分
        //setTimeout(function(){
        var test = window.location.href;
        if(test.match("train/home")){
            document.querySelector(".btn.to-learn").click ();
            window.close();
        }else if(test.match("grain/course")){
            x1 = document.querySelector(".state").innerText;//学习
            t1 = window.setInterval(study,10000);//重复执行某个方法
        }else if(test.match("train/guide/course")){
            setTimeout( Select,5000);//选视频
        }else if(test.match("train/pointView")){
            nldxz(); //能力点选择
        }else if(test.match("train/workspace")){
            if(document.querySelectorAll('.score')[3].innerText!=zf1){
                page(0);
            }else if(document.querySelectorAll('.score')[4].innerText!=zf2){
                page(1);
            }else{window.alert("恭喜您已学完全部课程!")}
        }else if(test.match("videoPlay/play")){
            setTimeout(function(){GXstudy()},10000);//公需科目学习
        }
       else if(test.match("index.html#/v_video")){
           setTimeout(function(){
            window.open(document.querySelector('iframe').src),
            window.close();
            },10000);
        }else if(test.match("v_courseDetails")){
            setTimeout(function(){
                GXSelect()//公需科目选择
                setTimeout(function(){t1 = window.setInterval(location.reload(),60000)},60000)
            },10000);
        }else if(test.match("v_selected_course")){
            setTimeout(function(){
                document.querySelectorAll("label")[1].click()
                setTimeout(function(){
                    var list=document.querySelectorAll(".bg.pa.tc")
                    if(list.length){
                        list[0].click()
                        setTimeout(function(){t1 = window.setInterval(location.reload(),60000)},60000)
                    }else{window.alert("恭喜您已学完全部课程!")}
                },5000)
            },10000);
        }
  
       //},10000);
        //能力点选择
        function nldxz() {
            var sw=document.querySelectorAll('.ability-task-title');
            if(sw.length!=0){
                if(document.querySelector ('.info').innerText.match("3 个 / 3个")==null){
                    for (i = 0; i < sw.length; i++) {
                        sw[i].click ();
                    }
                    setTimeout(function(){
                        switch(document.querySelector ('.info').innerText) {
                            case "0 个 / 3个":
                                page(0);
                                break;
                            case "1 个 / 3个":
                                page(1);
                                break;
                            case "2 个 / 3个":
                                page(2);
                                break;
                            default:
                        }
                    },5000);
                }else{
                    document.querySelector ('.g-nav-menu-name').click ();
                    setTimeout(function(){
                        location.reload();
                    },5000);
                }
            }else{
                var nldqd=document.querySelectorAll ('span');
                while (nldqd[i].innerText.indexOf('确定(3)') == -1){
                    i++;
                }
                nldqd[i].click ();
                setTimeout(function(){
                    location.reload();
                },5000);
            }
        }
        //切换窗口
        function page(x) {
            document.querySelectorAll ('.task-title')[x].click ();
            window.close();
        }
        //选择视频
        function Select() {
            window.clearInterval(t1);
            var div = document.querySelectorAll(".item-infos.default")
            if(div.length!=0){
                document.querySelector(".img").click ();
                window.close();
            }else{
                document.querySelector ('.ivu-page-next').click ();
                setTimeout( Select,5000);
            }
        }
        //能力点学习
        function study() {
            if(i<7){
                i++;
                var str1 =document.querySelector('.vcp-controls-panel.show');
                var str2 =document.querySelector ('.alarmClock-wrapper');
                if(str1!=null){
                    document.querySelector ('.vcp-playtoggle').click ();
                }
                if(str2.style.display==""){
                    str2.click ();
                }
                if(document.querySelector(".scoring-wrapper").style.display!="none"){
                    var mousemove = new Event('mousemove');
                    var x=document.querySelectorAll(".rate-item")
                    x=x[x.length-1];
                    x.dispatchEvent(mousemove);
                    x.click();
                    setTimeout(function(){
                        document.querySelector ('.ivu-btn.ivu-btn-primary').click ();
                    },3000);
                }
            }else{
                i=0;
                var x2 = document.querySelector(".state").innerText;
                console.log(x2);
                if(x2!=x1){
                    x1=x2;
                }else{
                    window.clearInterval(t1);//你已学完本课,结束本课学习。
                    document.querySelector ('.g-nav-menu-name').click ();//换课
                }
            }
        }
        function GXstudy() {
            var txt,Time
            var x=document.getElementsByTagName("script")
            for(var i=0;i<x.length;i++){
                if(x[i].text.match("studyCode")){
                    txt=x[i].text
                    console.log(txt);
                    break;}
            }
            txt=txt.substring(txt.indexOf("管理员测试时使用"),txt.indexOf("if (attrset.updateRedisMap"))
            txt=txt.substring(txt.indexOf("管理员测试时使用"),)
            var reg = new RegExp('"',"g");
            txt = txt.replace(reg, "");
            reg = new RegExp('=',"g");
            txt = txt.replace(reg, ":");
            var sectionId=txt.substring(txt.indexOf("sectionId"),txt.indexOf(";"))
            sectionId=sectionId.substring(sectionId.indexOf(":")+2,)
            txt=txt.substring(txt.indexOf("signId"),)
            var signId=txt.substring(txt.indexOf("signId"),txt.indexOf(";"))
            signId=signId.substring(signId.indexOf(":")+2,)
            txt=txt.substring(txt.indexOf("recordId"),)
            var recordId=txt.substring(txt.indexOf("recordId"),txt.indexOf(";"))
            recordId=recordId.substring(recordId.indexOf(":")+2,)
            txt=txt.substring(txt.indexOf("updateRedisMap"),)
            var updateRedisMap=txt.substring(txt.indexOf("updateRedisMap"),txt.indexOf(";"))
            updateRedisMap=updateRedisMap.substring(updateRedisMap.indexOf(":")+2,)
            txt=txt.substring(txt.indexOf("studyCode"),)
            var studyCode=txt.substring(txt.indexOf("studyCode"),txt.indexOf(";"))
            studyCode=studyCode.substring(studyCode.indexOf(":")+2,)
            var maxTime=document.querySelector('video').duration;
            if(maxTime > 29*60){
                Time=maxTime*0.98
            }else if(maxTime > 18*60){
                Time=maxTime*0.97
            }else if(maxTime > 15*60){
                Time=maxTime*0.96
            }else if(maxTime > 13*60){
                Time=maxTime*0.95
            }else if(maxTime >10*60){
                Time=maxTime*0.94
            }else if(maxTime > 8*60){
                Time=maxTime*0.93
            }else{Time=maxTime*0.9};
            $.ajax({
                url: "/videoPlay/takeRecord",
                data: {
                    studyCode: studyCode,
                    updateRedisMap: updateRedisMap,
                    recordId: recordId,
                    sectionId: sectionId,
                    signId: signId,
                    time: Time,
                    businessId: "gp5"
                },
                dataType: "json",
                type: "post",
            })
            window.close();
        }
        //公需科目选择
        function GXSelect() {
            var list=document.querySelectorAll(".titlecolor.text")
            var s=document.querySelectorAll(".button.fr.mt10.mr20.border-public.tc.f14.titlecolor")
            for (var i = 0; i < list.length; i++) {
                if(s[i].text.match("未学习")){
                    list[i].click()
                    break;
                }
                document.querySelector(".f12.bnone").click()
            }
        }
    }
    catch(err) {
        var t = window.setInterval(location.reload(),10000);
    }
}