宁波干部党员学习网

自动学习

当前为 2021-06-04 提交的版本,查看 最新版本

// ==UserScript==
// @name         宁波干部党员学习网
// @namespace    http://nb.nbstudy.gov.cn/vm/login.jsp
// @version      1.1
// @description  自动学习
// @author       dahuilang
// @match        http://nb.nbstudy.gov.cn/*
// @icon         data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Your code here...

    var pageList=['http://nb.nbstudy.gov.cn/vm/class/show','http://nb.nbstudy.gov.cn/vm/course'] //启用脚本的页面
    var isStart = false;
    for(var pIndex=0;pIndex<pageList.length;pIndex++){
        
        if(location.href.indexOf(pageList[pIndex])>=0){
            
            isStart = true;
        }
    }

    if(isStart){


   var idList=[];

    //获取当前页所有视频的ID
    var interval = setInterval(function(){

       if(idList.length==0){
          var divList = $(".box2.class_box");
           for(var i=0;i<divList.length;i++){
               var c = divList[i];
               var link = $(c).attr("onclick");
               var gid= link.split(",")[0].split("(")[1].replace(/'/g,'');
               idList.push(gid);
           }

       }else{
             clearInterval(interval);
             query(idList,function(notCompleteId){

                 if(notCompleteId){
                    play(notCompleteId)
                 }else{
                     var url = location.href;
                     var pageNoIndex = url.indexOf("pageNo=")
                     var pageNo = 1;
                     if(pageNoIndex>=0){
                         pageNo = url.substring(pageNoIndex+"pageNo=".length)
                     }

                   location.href="http://nb.nbstudy.gov.cn/vm/course/?sid=0&pageNo="+(new Number(pageNo)+1) //翻页到下一页

                 }
             })
       }


    },1000)


    //获取cardid
    function getCardId(){
         var html =  document.documentElement.innerHTML
             var cardidIndex = html.indexOf("cardid=");
             if(cardidIndex>=0){
                html = html.substring(cardidIndex+"cardid=".length)
             }
             var cardid = html.split("&")[0];
        return cardid

    }


    //获取到未播放完成的视频
    function query(list,callback){

       var cardid = getCardId();

        $.ajax({
				   type: "GET",
				    url: "/in/GET-STUDY-SUM.phtml?cardid="+cardid+"&oid="+Math.random(),
				    dataType: 'json',
				   success: function(data){

                       console.log(data)

                       var notCompleteId = null;

                       for(var i=0;i<list.length;i++){
                           var id = list[i];

                           var isComplete = false;
                           for(var j=0;j<data.length;j++){
                              var c = data[j];
                              if(id == c.videoId && c.ccc=="100"){ //已经完成观看
                                 isComplete = true;
                                  break;
                              }
                           }//end for

                          if(!isComplete){
                              notCompleteId = id;
                              break;
                          }
                       }//end for

                        callback(notCompleteId)
				   }
				});

    }

    //模拟播放
    function play(videoId){

        var cardid = getCardId();

        var p2 = 60;

        //window.open('/vm/course/play.jsp?cid='+id,'_bkc')

        var playInterval = setInterval(function(){
             $.ajax({
				   type: "GET",
				    url: "/in/CAL.jsp?rid=0&cardid="+cardid+"&videoId="+videoId+"&p1=0&p2="+p2,
				    dataType: 'json',
				     success: function(data){

                       console.log(data)

                       //查询该视频的播放进度是否100%,如果是则刷新页面
                      query([videoId],function(notCompleteId){

                            if(notCompleteId){


                            }else{
                                 location.reload()

                            }



                      })


				   }
				});

            p2 = p2+60;

        },60000)



    }

 }





    
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址