var body = $("body") var button = $("<li id='set'></li>") button.html("<span id='start'>开启自动播放模式</span>") var json = { "background": "#36f", "height": "16px", "padding": "5px", "z-index": 999, // Stay top "cursor": "pointer", "bottom": "0", "left": "0", "color": "#fff", "position": "fixed" }; button.css(json); body.append(button)
// Index of current video var index = 0; $(".posCatalog_select").each((i, item) => { if ($(item).hasClass("posCatalog_active")) { index = i; returnfalse; } });
console.log("第" + (index + 1) + "个视频开始播放");
// Blacklist of course id, courses in this list will be skipped var blacklist = [];
functionautoNext() { index++; var selectID = $(".posCatalog_select")[index].id; while (selectID.indexOf('cur') == -1 || blacklist.indexOf(selectID) != -1) inedx++; console.log("第" + (index + 1) + "个视频开始播放"); var next = document.querySelectorAll(".posCatalog_select")[index].querySelector(".posCatalog_name"); next.click(); }
var progressRecord = -1;
button.click(function () {
setInterval(function () { // Get iframe var video = $("iframe").contents().find("iframe").contents(); // Get video progress 0~100 float var spans = video.find("#video > div.vjs-control-bar > div.vjs-progress-control.vjs-control > div").attr("aria-valuenow"); var play = function () { if (spans == progressRecord) { video.find("#video > button").click(); console.log("视频被暂停,已继续"); } progressRecord = spans; var slience = video.find("#video > div.vjs-control-bar > div.vjs-volume-panel.vjs-control.vjs-volume-panel-vertical > button"); // Mute if (slience.attr("title") != "取消静音") { slience.click(); } } var load = video.find("#loading"); if (load.css("visibility") != "hidden") { returnfalse; } if (spans != 100) { play(); } else { console.log("第" + (index + 1) + "个视频播放完成"); autoNext(); } $("#start").html("自动模式已开启,本视频进度:" + spans + "%"); }, 2000); });