// ==UserScript== // @name 大连理工大学视频倍速+自动切换脚本 // @run-at document-start // @version 0.2 // @description 大连理工大学视频倍速+自动切换脚本 // @author cangxun // @match https://learn.open.com.cn/StudentCenter/CourseWare/ShowResource* // @icon https://www.google.com/s2/favicons?domain=open.com.cn // @grant unsafeWindow // ==/UserScript== 'use strict'; (function() { var rate = 16; //倍速调节,最多16 var autoNext = true; //是否自动下一个 true为自动,false为不自动 //可能会出现不自动下一个,重播的情况,需要退出账号后重新登录。请确保网络质量!! //----------------------以下为逻辑代码----------------------------------- let hookSetInterval=unsafeWindow.setInterval; unsafeWindow.setInterval=function(a,b){ return hookSetInterval(a,b/rate); } function addCookie(objName, objValue, objHours) { var str = objName + "=" + escape(objValue); if (objHours > 0) { var date = new Date(); var ms = objHours * 3600 * 1000; date.setTime(date.getTime() + ms); str += "; expires=" + date.toGMTString(); } document.cookie = str; } unsafeWindow.onload = function () { //去除暂停广告 addCookie("qrcode_show_s",0,0); let iframe = unsafeWindow.document.getElementById('ifr'); let iframeUrl = iframe.src; iframe.onload = function () { let videoObj; let videoLoad = unsafeWindow.setInterval(function () { videoObj = iframe.contentWindow.document.querySelector('video'); if (videoObj) { videoObj.playbackRate = rate; videoObj.volume = 0; if (videoObj.paused) { videoObj.play(); unsafeWindow.clearInterval(videoLoad); videoObj.addEventListener("ended", function () { if(autoNext){ document.getElementsByClassName('icon-open-next')[0].click(); } }); } } }, 3000*rate); } iframe.src = iframeUrl; } })();