实现超星网课自动播放

实现超星网课自动播放

废话不多说直接上代码,放在console 里面运行

var fa = $("body");
var btn = $("
  • "
    ); var json = { "background": "#31e16d", "height": "16px", "padding": "5px", "z-index": 999999, "cursor": "pointer", "top": "300px", "right": "120px", "position": "fixed" }; btn.css(json); btn.html("开启自动播放模式"); fa.append(btn); btn.click(function () { var i = 2; //那一章 下标 我看到了地二章 var j = 1; //节 下标 var time = setInterval(function () { //获取iframe var video = $("iframe").contents().find("iframe").contents(); //播放函数 var play = function () { video.find("#video > button").click(); //点击播放按钮 var jy = video.find("#video > div.vjs-control-bar > div.vjs-volume-panel.vjs-control.vjs-volume-panel-vertical > button"); if (jy.attr("title") != "取消静音") { jy.click() } }; //正在加载 var load = video.find("#loading"); if (load.css("visibility") != "hidden") { return; } //获取进度 var spans = video.find("#video > div.vjs-control-bar > div.vjs-progress-control.vjs-control > div").attr("aria-valuenow"); // 如果还没播放完 if (spans != 100) { play(); } //如果播放结束 进行下一次播放 if (spans == 100) { j+=1; var allcells = $(".onetoone").find(".cells"); //所有章 var allncells = $(allcells[i]).find(".ncells"); //所有节 if (j >= allncells.length){ i+=1; j=0; allncells = $(allcells[i]).find(".ncells"); //所有节 } if (i >=allcells.length){ //停止播放 clearInterval(time); return false; } var a = $(allncells[j]).find("a").attr("href"); //获取 getTeacherAjax('204834487','9589145','158704904'); var KhindexOf = a.indexOf("("); var KhlastIndexOf = a.lastIndexOf(")"); var aStr = a.slice(KhindexOf+1,KhlastIndexOf); aStr = aStr.match(/'(\S*)'/)[1]; var reg = new RegExp("'", "g"); aStr = aStr.replace(reg, ""); var aArr = aStr.split(","); getTeacherAjax(aArr[0],aArr[1],aArr[2]); } $("#lfsenior").html("自动模式已开启,本章进度:" + spans + "%"); }, 100); });

    你可能感兴趣的:(前端)