// ==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 = `