// ==UserScript== // @name onlinedu自动播放 // @namespace c-h.cc // @version 0.7.1 // @description 自动点击播放器元素以继续播放 // @author JKRaks // @match *://www.onlinedu.org.cn/* // @include http://www.onlinedu.org.cn/* // @include https://www.onlinedu.org.cn/* // @require https://lib.baomitu.com/jquery/3.5.1/jquery.min.js // @require https://cdn.bootcdn.net/ajax/libs/layer/3.1.1/layer.min.js // @icon http://www.onlinedu.org.cn/images/logo.gif // @license GPL License // @grant GM_setValue // @grant GM_getValue // @grant GM_setClipboard // @grant GM_info // @grant GM_xmlhttpRequest // @grant GM.getValue // @grant GM.setValue // @grant GM.setClipboard // @grant GM.info // @grant GM.xmlHttpRequest // @downloadURL https://update.greasyfork.icu/scripts/419126/onlinedu%E8%87%AA%E5%8A%A8%E6%92%AD%E6%94%BE.user.js // @updateURL https://update.greasyfork.icu/scripts/419126/onlinedu%E8%87%AA%E5%8A%A8%E6%92%AD%E6%94%BE.meta.js // ==/UserScript== (function() { //框架渲染 $("head").append('') $("head").append('') $("head").append('') $("head").append('') $("head").append('') layer.open({ type: 1, id:'uul', title: '运行日志', shadeClose: true, shade: false, offset: 'r', area: ['200px', '410px'], content: '
设置选课延迟

停止脚本重新运行脚本

当前播放状态:

', }); layer.open({ type: 1, id:'setTime', title: '延迟选课设置', shadeClose: true, shade: false, area: ['240px', '170px'], content: '
单位:毫秒;请根据网页加载速度修改

当前:    默认:

    3000
', cancel: function(){ //右上角关闭回调 $("#layui-layer2").hide(); return false } }); $("#layui-layer2").hide(); //程序入口 function Inside(){ setSelectClassTimer() setAutoVedioTimer() } //定义定时器 var outTimer; var intTimer; var loadTime; //取出延迟启动值 try{ loadTime = GM_getValue('loadTime',3000) } catch(err){ GM_setValue('loadTime',3000) loadTime = 3000 } //设置自动选课定时器 function setSelectClassTimer(){ //自动选课 outTimer=setTimeout(function(){ AutoSelectCalss(); },loadTime); } //自动选课方法 function AutoSelectCalss(){ var $Lst=$(".el-progress__text") for(var i=0;i<$Lst.length;i++){ if($Lst.eq(i).text()!="100%"){ if(!$Lst.eq(i).parent().parent().parent().parent().prev().find("h3").prev().is('.hj_bg_color')) $Lst.eq(i).parent().parent().parent().parent().prev().find("h3").click() $Lst.eq(i).parent().parent().click() $Lst.eq(i).click() return; } layer.msg('自动选课已运行完毕,若未自动选课,则请手动选课'); } } //等待时间设置 var stayTime; //取出等待时间 try{ stayTime = GM_getValue('stayTime',33) } catch(err){ GM_setValue('stayTime',33) stayTime = 33 } //缓冲次数 var loadingTime=0; //设置自动播放定时器 function setAutoVedioTimer(){ //定时判断视频是否暂停 intTimer=setInterval(function(){ try{ var vdo =$('video').get(0) var State = vdo.paused if(State){ ck() } //判断是否在缓冲 if($("#dplayer").is(".dplayer-loading")){ loadingTime+=1; $("#nowIsLoading").text("缓冲中") }else if($("#dplayer").is(".dplayer-playing")){ loadingTime=0; $("#nowIsLoading").text("播放中") } //连续缓冲时间超过等待时间则重新载入页面 if(loadingTime>stayTime){ window.location.reload(); } checkPage() } catch(err){ checkPage() } },300) } //重放日志 function ck(){ $(".dplayer-video-wrap").click() $("#uul li:eq(0)").before('
  • '+getNow()+'重新播放
  • ') } //时间获取 function getNow() { var myDate = new Date(); var month=myDate.getMonth()+1; var date=myDate.getDate(); var h=myDate.getHours(); var m=myDate.getMinutes(); var s=myDate.getSeconds(); var now = month+'/'+date+' '+h+':'+m+':'+s; return now } //检查页面是否为课程视频页面 function checkPage(){ if(window.location.pathname!='/video'){ clearTimer() $("#nowIsLoading").text("检测到当前页面不是播放页面,已停止运行脚本") } } //定时器清除 function clearTimer(){ clearInterval(outTimer); clearInterval(intTimer); } //显示延迟加载 $("#btnLoadTime").click(function(){ $("#layui-layer2").show() $("#NowLoadTime").text(GM_getValue('loadTime',3000)) }) //自定义延迟启动 $("#btnUpdateLoadTime").click(function(){ var Time = $("#txtNum").val(); if (!(/(^[1-9]\d*$)/.test(Time))) layer.msg("有误") else{ layer.msg("启动延迟设置为 "+Time+" ms") GM_setValue("loadTime",Time) $("#layui-layer2").hide(); } }) $("#btnReloadScript").click(function(){ clearTimer() Inside(); $("#uul li:eq(0)").before('
  • 脚本已重新运行
  • ') }) $("#btnStopScript").click(function(){ clearTimer() $("#uul li:eq(0)").before('
  • 脚本已停止
  • ') }) Inside(); })();