基础教育教师培训网,全自动学习!

https://jx19qy.gpa.enetedu.com/

目前为 2022-07-26 提交的版本。查看 最新版本

// ==UserScript==
// @name         基础教育教师培训网,全自动学习!
// @namespace    https://greasyfork.org/
// @version      0.3
// @description  https://jx19qy.gpa.enetedu.com/
// @author       You
// @match        https://jx19qy.gpa.enetedu.com/mycourse/MyCourse/MyEventList*
// @match        https://jx19qy.gpa.enetedu.com/Event/MyjoinEvent*
// @match        https://jx19qy.gpa.enetedu.com/Event/CourseWare*
// @match        https://jx19qy.gpa.enetedu.com/MyCourse/Process*
// @require      https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js
// @grant        GM_setValue
// @grant        GM_getValue
// ==/UserScript==

(function() {

    window.onload=function(){
        if((window.location.href).substring(0,78)==='https://jx19qy.gpa.enetedu.com/mycourse/MyCourse/MyEventList?studentproject_id')
        {
            var main_1=[];
            $(".item li").each(function(){
                var url=$(this).find("a").attr("href");
                var url_ok=$(this).find("i").html();
                if(url_ok==="[未完成]"){
                    var s={"url":url};
                    main_1.push(s);
                }
            });
            GM_setValue("list",[]);
            GM_setValue("list_url",[]);
            if(main_1.length>0){
                alert("你还有:"+main_1.length+"个任务未完成!下面将自动获取未完成学习的每一个子项,请不要操作电脑!完成扫描后将自动开始学习!!");
                saomiao(main_1);
            }else{
                alert("你已完成全部学习任务!");
            }
        }
        if((window.location.href).substring(0,47)==="https://jx19qy.gpa.enetedu.com/MyCourse/Process"){
            get_play_time();
        }
    }
    function get_play_time(){

        const loop = setInterval(() => {
            //var ss=document.getElementsByClassName("qplayer-currtime");
            //console.log(ss.html);

        },4000);
    }
    function saomiao(main_1){
        var xuexi_list_1=main_1;
        var winURL=null;
        var main_n=0;
        if(main_n<xuexi_list_1.length){
            winURL= window.open(xuexi_list_1[main_n].url+"&ss=1", '_blank');
            const loop = setInterval(() => {    // 使用定时器查询当前状态
                if (winURL && winURL .closed) {  // 进行判断条件   closed属性就是返回当前窗口的状态
                    main_n++;
                    if(main_n<xuexi_list_1.length){
                        winURL= window.open(xuexi_list_1[main_n].url+"&ss=1", '_blank');
                    }else{
                        clearInterval(loop);       // 清除定时器
                        console.log(GM_getValue("list"));
                        get_s_url(xuexi_list_1);
                    }
                }
            }, 500);
        }
    }
    function get_s_url(xuexi_list_1){
        var tt=GM_getValue("list");
        var winURL=null;
        var main_n=0;
        if(main_n<tt.length){
            var tt_s=tt[main_n].split(",");
            winURL= window.open(tt_s[2]+"&tt="+main_n, '_blank');
            const loop = setInterval(() => {    // 使用定时器查询当前状态
                if (winURL && winURL .closed) {  // 进行判断条件   closed属性就是返回当前窗口的状态
                 console.log(GM_getValue("list_url").length);
                    main_n++;
                    if(main_n<tt.length){
                        var tt_s=tt[main_n].split(",");
                        winURL= window.open(tt_s[2]+"&tt="+main_n, '_blank');
                    }else{
                        clearInterval(loop); // 清除定时器
                        study_s();
                    }
                }
            }, 500);
        }
    }
    function study_s(){
    var tt=GM_getValue("list_url");
        var winURL=null;
        var main_n=0;
        if(main_n<tt.length){
            winURL= window.open(tt[main_n], '_blank');
            const loop = setInterval(() => {    // 使用定时器查询当前状态
                if (winURL && winURL .closed) {  // 进行判断条件   closed属性就是返回当前窗口的状态
                    main_n++;
                    if(main_n<tt.length){
                        winURL= window.open(tt[main_n], '_blank');
                    }else{
                        clearInterval(loop); // 清除定时器
                    }
                }
            }, 500);
        }
    }

    setInterval(function() {
        if((window.location.href).substring(0,48)==="https://jx19qy.gpa.enetedu.com/Event/MyjoinEvent")
        {
            var url1=window.location.href;
            if(getQueryString("ss")!==null){
                var list=[];
                var url=url1.replace("https://jx19qy.gpa.enetedu.com","").replace("&ss=1","");
                $("table tbody tr td a").each(function(){
                    var s=($(this).attr("href"));
                   // if(s.trim()!=="javascript:hideMask_master"){
                        s=s.replace("javascript:ShowCourseware","");
                        s=s.replace("(","");
                        s=s.replace(")","");
                        s=s.replace("''",url);//.replace("https://jx19qy.gpa.enetedu.com","")
                        if(s!==""&&s!=undefined){
                            var ss=s.split(",");
                            if(ss[1]!=null){
                                list.push(s);
                            }
                        }
                   // }
                });
                set_v(list);
            }
            if(getQueryString("tt")!==null){
                var n=getQueryString("tt");
                var ss1=GM_getValue("list");
                var dd=ss1[n].split(",");
                ShowCourseware(dd[0],dd[1],'')
            }
        }
        if((window.location.href).substring(0,47)==="https://jx19qy.gpa.enetedu.com/Event/CourseWare"){
            var sss=[];
            $("table tbody tr").each(function(){
                var url=$(this).find("a").attr("href");
                var url_ok=$(this).find("span").html();
                var time=$(this).find("span").parent().prev().html();

                if(url_ok!== undefined && url!==undefined &&  (url_ok.indexOf("未学完") !== -1||url_ok.indexOf("未开始") !== -1)){

                    var t= ClearBr(time);
                    var f=(Number(t.split("分")[0])+1)*60;
                    var ut=url+"&t="+f;
                    sss.push(ut);
                }
            });
            set_url(sss);
        }
        if((window.location.href).substring(0,47)==="https://jx19qy.gpa.enetedu.com/MyCourse/Process"){
            var t=Number(getQueryString("t"));
            st_time++;
            if(st_time>=t){
               window.close();
            }
        }
}, 1000);
    var st_time=0;
    function set_url(u){
        var a=GM_getValue("list_url");
        var b=u;
        var c=b.concat(a);
        var d=repeat(c)
        GM_setValue("list_url",[]);
        GM_setValue("list_url",d);
        console.log(GM_getValue("list_url").length);
        window.close();
    }
    function set_v(u){
        var a=GM_getValue("list");
        var b=u;
        var c=b.concat(a);
        var d=repeat(c)
        GM_setValue("list",[]);
        GM_setValue("list",d);
        window.close();
        //alert(GM_getValue("list"));

    }
    //去除HTML标签
    function clear_html(html){
        return html.toString().replace(/<[^>]+>/g,"").innerText;//去掉所有的html标记
    }
    //获取url地址去除&t=XXX
    function get_url(url) {
        if(url===undefined)
        {
            return "";
        }else{
            var n=url.indexOf("&t=");
            var s=url.substring(0,n)
            return s;
        }
    }
    //获取参数t(要播放的时间单位为分钟)
    function getQueryString(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
    var r = window.location.search.substr(1).match(reg);
    if (r != null) return unescape(r[2]); return null;
    }
    function ClearBr(key) {
key = key.replace(/<\/?.+?>/g,"");
key = key.replace(/[\r\n]/g, "");
    key = key.replace(/\s+/g, "");
return key;
}
//去除重复数组
    function repeat(arr) {

            for (var i = 0; i < arr.length; i++) {
                for (var j = i + 1; j < arr.length; j++) {//第一次是拿第一个数据和剩余的n-1个数据判断是否相等、第二次是拿第二个数据和剩余的n-1个数据相比
                    if (arr[i] == arr[j]) {

                        var del = j;

                        arr.splice(del, 1);//找到了该数据的下标就删除了
                    }
                }
            }
            return arr;
        }
})();