// ==UserScript==
// @name 🍀八大员|三类人|住房城乡建设行业从业人员教育培训平台|使用说明:http://doc.zhanyc.cn/pages/bdyslr/
// @namespace free
// @version 1.0
// @description 当前是免费版本,只包含了解除视频暂停限制功能。如需自动下一集、自动换课程、全自动无人值守等高级功能可升级付费版本|接各类脚本开发、代挂任务,微信:zhanyc_cn 个人网站:http://doc.zhanyc.cn
// @include *://*etledu.com*
// @include *://*.etledu.com/*
// @include *://*.gsjtpxzx.com/*
// @grant GM_getValue
// @grant GM_setValue
// @grant GM_deleteValue
// @grant window.close
// @run-at document-end
// @require http://libs.baidu.com/jquery/2.0.0/jquery.min.js
// @license MIT
// ==/UserScript==
(function () {
let $jq = $;
unsafeWindow.$jq = $;
let xyDocUrl = "http://doc.zhanyc.cn/pages/bdyslr/";
let xyIsDev = true;
let xyApp = {
pageData: {
videoTimer: null,
waitTime: 0,
checkTimes: 0,
videoStarted: false,
},
// 等待条件满足
xyWaitOf(fun, interval, timeout) {
interval = interval || 1000;
timeout = timeout || 30;
return new Promise((resolve, reject) => {
let _timeOut = timeout * 1000;
try {
if (fun()) return resolve();
} catch (e) { }
let index = setInterval(() => {
try {
if (timeout != -1) {
_timeOut -= interval;
if (_timeOut < 0) {
clearInterval(index);
return reject();
}
}
if (fun()) {
clearInterval(index);
return resolve();
}
} catch (e) { }
}, interval);
});
},
// 等待指定毫秒
xyWaitMs(ms) {
return new Promise((resolve) => {
setTimeout(resolve, ms);
});
},
// 获取视频元素
xyGetVideo() {
return $("video")[0];
},
// 播放视频
xyPlayVideo() {
let v = xyApp.xyGetVideo();
if (v) {
v.volume = 0;
setTimeout(() => { v.play(); }, 200);
}
},
// 获取当前播放时间
xyGetCurTime() {
try { return xyApp.xyGetVideo().currentTime; } catch (e) { return 0; }
},
// 获取视频总时长
xyGetTotalTime() {
try { return xyApp.xyGetVideo().duration; } catch (e) { return 0; }
},
// 检测视频是否在播放中
xyVideoIsPlaying() {
return new Promise((resolve) => {
try {
let curTime = xyApp.xyGetCurTime();
setTimeout(() => {
let t1 = xyApp.xyGetCurTime();
if (t1 > curTime) {
setTimeout(() => {
let t2 = xyApp.xyGetCurTime();
resolve(t2 > t1);
}, 100);
} else {
resolve(false);
}
}, 100);
} catch (e) {
resolve(false);
}
});
},
// 检测播放是否完成
xyIsPlayDone() {
try {
return xyApp.xyGetTotalTime() > 0 && xyApp.xyGetCurTime() + 5 >= xyApp.xyGetTotalTime();
} catch (e) { return false; }
},
// 更新悬浮面板视频状态
xyUpdateVideoStatus() {
let $panel = $("#xy_free_panel");
if ($panel.length == 0) return;
let curTime = xyApp.xyGetCurTime().toFixed(0);
let totalTime = xyApp.xyGetTotalTime().toFixed(0);
let pct = 0;
if (Number(totalTime) > 0) {
pct = ((Number(curTime) / Number(totalTime)) * 100).toFixed(1);
}
$("#xy_video_status").html(`▶ 视频播放中
进度:${curTime}s / ${totalTime}s(${pct}%)`);
},
// 在悬浮面板显示提示信息
xyShowPanelTip(msg, color) {
color = color || "#ff6600";
let $tip = $("#xy_panel_tip");
if ($tip.length == 0) {
$("#xy_free_panel .xy_panel_body").append(`