// ==UserScript== // @name 自考365免费版|如需自动下一集、自动换课程、秒过、考试答题等高级功能见收费版本:http://doc.zhanyc.cn/pages/zk365/ // @run-at document-end // @version 1.0 // @description 当前是免费版本,只包含了视频页面自动播放、解除播放暂停限制功能。如需自动下一集、自动换课程、秒过、考试答题、全自动无人值守高级功能可升级付费版本|接各类脚本开发、代挂工作,微信:zhanyc_cn 个人网站:http://doc.zhanyc.cn // @include *://*.zikao365.com/* // @grant GM_addStyle // @grant window.close // @require http://libs.baidu.com/jquery/2.0.0/jquery.min.js // @antifeature payment // @license Creative Commons // ==/UserScript== (function () { let docUrl = "http://doc.zhanyc.cn/pages/zk365/"; let yxkt = { pageData: { videoTimer: null, waitTime: 0, }, async init() { console.log("%c yxkt init", "background:rgb(0,0,0);color:#fff"); yxkt.addPanelStyle(); await yxkt.waitForBody(); yxkt.createPanel(); let url = location.href; if ( url.includes("/xcware/video/videoPlay/videoPlayhls.shtm") || url.includes("/xcware/video/h5video/videoPlay.shtm") ) { yxkt.startVideo(); } else if (url.toLowerCase().includes("/examinationGckh".toLowerCase())) { yxkt.showExamTips(); } else if (url.toLowerCase().includes("/vqzs/shijuan/".toLowerCase())) { yxkt.showExamTips(); } else if (url.toLowerCase().includes("/vqzs/analysisGckh".toLowerCase())) { yxkt.showExamTips(); } // 监听URL变化(SPA页面切换) let lastUrl = location.href; setInterval(() => { if (lastUrl !== location.href) { lastUrl = location.href; yxkt.handleUrlChange(location.href); } }, 500); }, async handleUrlChange(url) { if ( url.includes("/xcware/video/videoPlay/videoPlayhls.shtm") || url.includes("/xcware/video/h5video/videoPlay.shtm") ) { yxkt.startVideo(); } else if (url.toLowerCase().includes("/examinationGckh".toLowerCase())) { yxkt.showExamTips(); } else if (url.toLowerCase().includes("/vqzs/shijuan/".toLowerCase())) { yxkt.showExamTips(); } else if (url.toLowerCase().includes("/vqzs/analysisGckh".toLowerCase())) { yxkt.showExamTips(); } else { yxkt.hideExamTips(); } }, // ========== 视频相关方法 ========== async startVideo() { console.log("%c yxkt startVideo", "background:rgb(0,0,0);color:#fff"); await yxkt.waitForEl(() => $("video").length > 0); await yxkt.sleep(1000); yxkt.showVideoStatus("视频功能运行中"); yxkt.play(); yxkt.updatePanelProgress(); yxkt.pageData.videoTimer = setInterval(async () => { try { if (yxkt.pageData.waitTime > 0) { yxkt.pageData.waitTime -= 2; return; } let video = yxkt.getVideo(); if (!video) return; video.volume = 0; let title = `进度:${yxkt.getCurTime().toFixed(0)}/${yxkt.getTotalTime().toFixed(0)}`; $("title").text(title); yxkt.updatePanelProgress(); let isFinish = yxkt.isPlayFinish(); if (isFinish) { yxkt.showVideoStatus("视频播放完成"); yxkt.pageData.waitTime = 10; return; } let isPlaying = await yxkt.videoIsPlay(); if (!isPlaying) { yxkt.play(); } if (video.playbackRate != 1) { video.playbackRate = 1; } } catch (e) { console.error("视频定时器出错", e); } }, 2000); // 监听视频事件 let video = yxkt.getVideo(); if (video) { video.addEventListener('play', () => { yxkt.showVideoStatus("视频播放中"); }); video.addEventListener('pause', () => { yxkt.showVideoStatus("视频已暂停 - 即将恢复播放"); setTimeout(() => { yxkt.play(); }, 500); }); } }, play() { let video = yxkt.getVideo(); if (!video) return; video.volume = 0; setTimeout(() => { video.play(); }, 200); }, getVideo() { return $("video")[0]; }, getCurTime() { let res = 0; try { res = yxkt.getVideo().currentTime; } catch (e) { console.error(e); } return res; }, getTotalTime() { let res = 0; try { res = yxkt.getVideo().duration; } catch (e) { console.error(e); } return res; }, isPlayFinish() { try { return yxkt.getTotalTime() > 0 && yxkt.getCurTime() + 10 >= yxkt.getTotalTime(); } catch (e) { return false; } }, async 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); } }); }, // ========== 答题页面引流提示 ========== showExamTips() { $("#yxktExamTips").remove(); let tipsHtml = `
⚠ 考试答题功能
当前页面支持自动答题功能
付费版本可实现秒过考试、自动答题、自动交卷等高级功能
一次付费,永久使用,免费维护更新
查看付费版本
接各类脚本开发、代挂工作,微信:zhanyc_cn
`; $("body").append(tipsHtml); }, hideExamTips() { $("#yxktExamTips").remove(); }, // ========== 悬浮面板 ========== addPanelStyle() { GM_addStyle(` #yxktPanel { position: fixed; left: 10px; top: 10px; z-index: 99998; background: rgba(0,0,0,0.85); color: #fff; border-radius: 8px; padding: 12px; font-size: 13px; min-width: 260px; max-width: 320px; box-shadow: 0 2px 12px rgba(0,0,0,0.3); font-family: Microsoft YaHei, sans-serif; line-height: 1.6; } #yxktPanel .yxkt-title { font-size: 15px; font-weight: bold; color: #00ffcc; border-bottom: 1px solid #333; padding-bottom: 8px; margin-bottom: 8px; } #yxktPanel .yxkt-close { position: absolute; top: 6px; right: 10px; cursor: pointer; font-size: 18px; color: #999; } #yxktPanel .yxkt-close:hover { color: #fff; } #yxktPanel .yxkt-video-status { background: #00cc66; color: #fff; padding: 6px 10px; border-radius: 4px; font-weight: bold; font-size: 14px; text-align: center; margin: 8px 0; display: none; } #yxktPanel .yxkt-progress { background: #333; border-radius: 4px; height: 20px; overflow: hidden; margin: 6px 0; display: none; } #yxktPanel .yxkt-progress-bar { background: linear-gradient(90deg, #00cc66, #00ffcc); height: 100%; width: 0%; transition: width 0.5s; border-radius: 4px; text-align: center; line-height: 20px; font-size: 12px; color: #000; font-weight: bold; } #yxktPanel .yxkt-tips { color: #ffcc00; font-size: 12px; margin: 6px 0; } #yxktPanel .yxkt-link { color: #00ccff; text-decoration: none; font-size: 12px; } #yxktPanel .yxkt-link:hover { text-decoration: underline; } #yxktPanel .yxkt-feature { color: #aaa; font-size: 12px; margin: 4px 0; } #yxktPanel .yxkt-feature span { color: #00ffcc; } `); }, createPanel() { if ($("#yxktPanel").length > 0) return; let panelHtml = `
🎬 自考365 免费版
▶ 视频功能运行中
0%
当前功能:视频自动播放 | 解除暂停限制
💡 付费版支持:自动下一集、自动换课程、秒过、考试答题、全自动无人值守
👉 升级付费版本(一次付费·永久使用·免费维护)
接各类脚本开发、代挂工作,微信:zhanyc_cn
`; $("body").append(panelHtml); $("#yxktPanelClose").on("click", function () { $("#yxktPanel").hide(); }); }, showVideoStatus(status) { $("#yxktVideoStatus").show().text("▶ " + status); $("#yxktProgress").show(); }, updatePanelProgress() { try { let cur = yxkt.getCurTime(); let total = yxkt.getTotalTime(); if (total > 0) { let pct = Math.min((cur / total * 100), 100).toFixed(1); $("#yxktProgressBar").css("width", pct + "%").text(pct + "%"); $("#yxktVideoStatus").show().text(`▶ 视频播放中 ${yxkt.formatTime(cur)}/${yxkt.formatTime(total)}`); } } catch (e) { } }, formatTime(seconds) { let m = Math.floor(seconds / 60); let s = Math.floor(seconds % 60); return (m < 10 ? "0" + m : m) + ":" + (s < 10 ? "0" + s : s); }, // ========== 工具方法 ========== waitForEl(fn) { return new Promise((resolve) => { if (fn()) return resolve(); let timer = setInterval(() => { if (fn()) { clearInterval(timer); resolve(); } }, 1000); }); }, waitForBody() { return new Promise((resolve) => { if ($("body").length > 0) return resolve(); let timer = setInterval(() => { if ($("body").length > 0) { clearInterval(timer); resolve(); } }, 500); }); }, sleep(ms) { return new Promise((resolve) => { setTimeout(resolve, ms); }); }, }; setTimeout(() => { if (typeof zfk === 'undefined') { yxkt.init(); } else { console.log('skip init - 付费版本已运行'); } }, 3000); })();