// ==UserScript== // @name 学达云|陕西省建设类执业师继续教育平台|解除视频暂停限制|如需自动下一集、自动换课程、考试答题等高级功能见收费版本:http://doc.zhanyc.cn/pages/xdy/ // @namespace free // @version 1.0 // @description 当前是免费版本,仅包含解除视频暂停限制功能。如需自动下一集、自动换课程、全自动无人值守等高级功能可升级付费版本。一次付费永久使用!|接各类脚本开发、代挂任务,微信:zhanyc_cn 个人网站:http://doc.zhanyc.cn // @include *://*.ok99ok99.com/* // @grant GM_addStyle // @run-at document-end // @require http://libs.baidu.com/jquery/2.0.0/jquery.min.js // ==/UserScript== (function () { let docUrl = "http://doc.zhanyc.cn/pages/xdy/"; let yxm = { pageData: { videoTimer: null, }, init() { console.log("%c yxm init", "background:rgb(0,0,0);color:#fff"); yxm.showFloatPanel(); yxm.runByUrl(location.href); }, runByUrl(url) { if (url.includes("/player2.aspx?")) { yxm.page_video(); } }, page_video() { console.log("%c page_video", "background:rgb(0,0,0);color:#fff"); let timeout = 2; let lastTime = null; let stuckCount = 60; let stuckCountBak = 60; yxm.pageData.videoTimer = setInterval(async () => { try { let video = document.querySelector("video"); if (!video) return; let curTime = video.currentTime; let duration = video.duration; if (curTime == lastTime) { stuckCount -= timeout; if (stuckCount <= 0) { stuckCount = stuckCountBak; video.currentTime = curTime + 1; } } else { lastTime = curTime; stuckCount = stuckCountBak; } let isPlay = await yxm.videoIsPlay(); if (!isPlay) { video.volume = 0; setTimeout(() => { video.play(); }, 200); } yxm.updateProgress(curTime, duration); } catch (e) { console.error("视频监控定时器出错", e); } }, timeout * 1000); }, videoIsPlay() { return new Promise((resolve) => { try { let curTime = $("video")[0].currentTime; setTimeout(() => { let time1 = $("video")[0].currentTime; let res = time1 > curTime; if (res) { setTimeout(() => { let time2 = $("video")[0].currentTime; let res2 = time2 > time1; resolve(res2); }, 100); } else { return resolve(false); } }, 100); } catch (e) { resolve(false); } }); }, updateProgress(curTime, duration) { if (duration > 0) { let pct = ((curTime / duration) * 100).toFixed(1); $("#yxmProgressText").text(`${curTime.toFixed(0)}s / ${duration.toFixed(0)}s`); $("#yxmProgressBar").css("width", pct + "%"); $("#yxmProgressPct").text(pct + "%"); } }, showFloatPanel() { let panelHtml = `