// ==UserScript== // @name 江西职培在线网课助手 // @namespace jiangxizhipeizaixian // @version 1.1 // @description 江西职培在线自动化助手 // @author Nanako660 // @match https://jiangxi.zhipeizaixian.com/study/video* // @icon https://www.google.com/s2/favicons?sz=64&domain=zhipeizaixian.com // @require https://cdnjs.cloudflare.com/ajax/libs/html2canvas/1.4.1/html2canvas.min.js // @grant GM_xmlhttpRequest // @grant GM_log // @grant GM_notification // @grant GM_setValue // @grant GM_getValue // @connect furina.one // @license MIT // @downloadURL https://update.greasyfork.icu/scripts/508682/%E6%B1%9F%E8%A5%BF%E8%81%8C%E5%9F%B9%E5%9C%A8%E7%BA%BF%E7%BD%91%E8%AF%BE%E5%8A%A9%E6%89%8B.user.js // @updateURL https://update.greasyfork.icu/scripts/508682/%E6%B1%9F%E8%A5%BF%E8%81%8C%E5%9F%B9%E5%9C%A8%E7%BA%BF%E7%BD%91%E8%AF%BE%E5%8A%A9%E6%89%8B.meta.js // ==/UserScript== (function () { 'use strict'; // #region 全局配置 // 自动播放视频 var isAutoPlay = GM_getValue('isAutoPlay', true); // 自动下一节 var isAutoNext = GM_getValue('isAutoNext', true); // 自动跳转最新课程 var isAutoJump = GM_getValue('isAutoJump', true); // 自动过人机验证 var isAutoVerify = GM_getValue('isAutoVerify', false); // 自动发送邮件通知 var isEmailNotice = GM_getValue('isEmailNotice', true); // 主循环间隔 var mainLoopInterval = GM_getValue('mainLoopInterval', 1000); // 调试模式 var isDebug = GM_getValue('isDebug', false); // 邮件地址 var localEmail = GM_getValue('localEmail', null); // #endregion // #region 常量 // 人机验证弹窗class const POP_WINDOWS_CLASS = '.zhipei-modal-content'; // 验证码弹窗特征class const CODE_CLASS = '.code_box___32BrH'; // 人脸弹窗特征class const FACE_CLASS = '.video_box___2zomT'; // 标题class const TITLE_CLASS = '.header_box_title___1INxv'; // 视频控件class const VIDEO_ID = 'J_prismPlayer'; // 目录class const CONTENTS_CLASS = '.content_box___1fOQp'; // 目录子项class const CONTENTS_ITEM_CLASS = '.content_box_wrap___ZdoU3'; // 目录子项标题class const CONTENTS_ITEM_TITLE_CLASS = '.units_title___1Js-7'; // 目录子项时长class const CONTENTS_ITEM_DURATION_CLASS = '.time_box___1PlPI'; // 目录子项链接class const CONTENTS_ITEM_LINK_CLASS = 'a.units_wrap_box___1ncip'; // 目录子项完成状态class const CONTENTS_ITEM_STATUS_CLASS = '.anticon-check-circle'; // 课程下一节按钮class const NEXT_BUTTON_CLASS = '.next_button___YGZWZ'; // 邮箱发送API const EMAIL_API_URL = 'https://furina.one/api/email.php'; // #endregion // #region 标志位 var isPopWindows = false; const FinishType = { NOT_FINISH: 0, FINISHED: 1, UPPER_LIMIT: 2 }; var finishType = FinishType.NOT_FINISH; // 验证类型 const VerifyType = { NONE: 0, CODE: 1, FACE: 2 }; var verifyType = VerifyType.NONE; // #endregion // #region 全局变量 // 主循环 var MainLoop; // 获取视频控件 var checkVideoInterval; // 全局悬浮窗 var shadowWindows; var updateDebugInfoInterval; // #endregion /** * 打印调试信息 * @param {string} message - 要打印的消息 */ function print(message) { if (isDebug) { console.log(message); } } // 等待视频加载完成 checkVideoInterval = setInterval(function () { if (getVideo()) { Main(); clearInterval(checkVideoInterval); } }, 1000); function Main() { print("职培在线网课助手脚本开始运行..."); if (isAutoJump) { autoJumpToLatestCourse(); } // 创建信息悬浮窗 createFloatingWindow(); // 主循环 mainLoop(); } function mainLoop() { MainLoop = setInterval(function () { if (finishType === FinishType.FINISHED || finishType === FinishType.UPPER_LIMIT) { alert("当前课程已完成或者每日学习时长已达8小时上限,脚本停止执行..."); clearInterval(MainLoop); return; } // 更新调试信息 if (isDebug) { updateDebugInfo(); } // 检测弹窗 let popWindows = getPopWindows(); if (isPopWindows) { print("等待人机验证..."); if (!popWindows) { isPopWindows = false; print("人机验证完成,继续播放视频..."); window.location.reload(); } return; } if (popWindows) { isPopWindows = true; checkPopWindowsType(popWindows); // 截取弹窗并发送邮件 if (isEmailNotice) { setTimeout(() => { sendNoticeEmail(POP_WINDOWS_CLASS); }, 3000); } } // 视频播放完毕,自动播放下一节 if (isAutoNext) { let video = getVideo(); if (video.currentTime >= video.duration) { getNextButtonAndClick(); return; } } // 自动播放视频 if (isAutoPlay && !isPopWindows) { let video = getVideo(); if (video.paused) { print("视频暂停,尝试继续播放..."); video.volume = 0; video.play(); } } }, mainLoopInterval); } function getPopWindows() { var popWindows = document.querySelector(POP_WINDOWS_CLASS) if (popWindows) { return popWindows; } return null; } function checkPopWindowsType(popWindows) { let code = popWindows.querySelector(CODE_CLASS); let face = popWindows.querySelector(FACE_CLASS); if (code) { verifyType = VerifyType.CODE; print("获取到人机验证弹窗,类型为验证码验证..."); print(code.querySelector('img').src); } else if (face) { verifyType = VerifyType.FACE; print("获取到人机验证弹窗,类型为人脸验证..."); } else { finishType = FinishType.UPPER_LIMIT; print("今日学习时长已达8小时上限..."); } } function sendNoticeEmail(item = null) { let title; if (verifyType === VerifyType.CODE) { title = "验证码验证"; } else if (verifyType === VerifyType.FACE) { title = "人脸验证"; } else { print("无弹窗,不发送邮件通知。"); return; } captureScreenshot(item).then(dataURL => { let subject = `江西职培在线网课助手${title}弹窗通知`; let lvideo = getVideo(); let message = `
课程信息:
课程标题: | ${getTitle()} |
视频时长: | ${lvideo.duration.toFixed(0)} 秒 |
已看时长: | ${lvideo.currentTime.toFixed(0)} 秒 |
${title}弹窗截图:
请尽快处理${title}弹窗,以免影响课程进度!
此邮件由江西职培在线网课助手自动发送,如有反馈可直接回复邮件,请勿泄露个人信息。
填写邮箱用于接收人机验证通知邮件
推荐使用QQ邮箱,手机下载QQ邮箱App设置通知优先级为高,以免错过通知
邮箱地址:
调试用,没事别乱点