// ==UserScript==
// @name 江西职培在线网课助手
// @namespace jiangxizhipeizaixian
// @version 1.0.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 none
// ==/UserScript==
(function () {
'use strict';
var isDebug = GM_getValue('isDebug', false);
var isCompleted = false;
// 全局邮件地址
var localEmail = GM_getValue('localEmail', null);
var isVerify = false;
var isMoal = false;
// 获取视频控件
var checkVideoInterval;
// 全局悬浮窗
var shadow;
// 监控视频播放
var monitorVideoInterval;
var updateDebugInfoInterval;
function print(message) {
if (isDebug) {
console.log(message);
}
}
function Main() {
print("职培在线网课助手脚本开始运行...");
// 创建信息悬浮窗
createFloatingWindow();
if (isCompleted) {
print("当前课程已完成,脚本停止执行...");
clearInterval(monitorVideoInterval);
return;
}
// 监控视频播放
monitorVideo();
}
checkVideoInterval = setInterval(function () {
if (getVideo()) {
print("视频控件已加载,开始运行...");
Main();
clearInterval(checkVideoInterval);
} else {
print("视频控件未加载,继续轮询...");
}
}, 500);
function getMoal() {
var moal = document.querySelector('.zhipei-modal-content')
if (moal) {
print("获取到人机验证弹窗,请手动完成人机验证!");
return moal;
}
return null;
}
function checkMoalType(moal) {
let num = moal.querySelector('.code_box___32BrH');
if (num) {
print("获取到人机验证弹窗,类型为数字验证码...");
print(num.querySelector('img').src);
}
}
function captureAndSendEmail(item = null) {
captureScreenshot(item).then(dataURL => {
let subject = '职培在线网课助手人机验证弹窗通知';
let lvideo = getVideo();
let message = `
职培在线网课助手
功能列表:
1.自动静音后台播放 ☑
2.自动播放下一节课程☑
3.自动过人机验证☐
3.邮件提醒人机验证☑
使用说明:
填写邮箱用于接收人机验证通知邮件
推荐使用QQ邮箱,手机下载QQ邮箱App设置通知优先级为高,以免错过通知
配置信息
邮箱地址:
调试信息
等待视频信息...
不要乱点
`;
shadow.appendChild(content);
// 将浮动窗口添加到文档中
document.body.appendChild(floatingWindow);
// 初始化复选框状态
shadow.querySelector('#debugMode').checked = isDebug;
// 监听复选框状态变化
shadow.querySelector('#debugMode').addEventListener('change', function () {
isDebug = this.checked;
GM_setValue('isDebug', isDebug);
shadow.querySelector('#debugContent').style.display = isDebug ? 'block' : 'none';
});
// 测试按钮功能
shadow.querySelector('#testButton1').addEventListener('click', function () {
//checkCurrentCourceIsCompleted(true);
captureAndSendEmail();
});
// 获取页面上的元素
var emailInput = shadow.querySelector('#emailInput');
var saveEmailButton = shadow.querySelector('#saveEmail');
// 初始化输入框的值为保存的邮箱
var savedEmail = GM_getValue('localEmail', '');
emailInput.value = savedEmail;
// 点击保存邮箱按钮的事件处理
saveEmailButton.addEventListener('click', function () {
var email = emailInput.value.trim();
if (email) {
GM_setValue('localEmail', email);
alert('邮箱地址已保存!请手动刷新网页生效!');
} else {
alert('请输入有效的邮箱地址。');
}
});
// 初始化调试信息的显示状态
shadow.querySelector('#debugContent').style.display = isDebug ? 'block' : 'none';
// 更新调试信息
setInterval(function () {
updateDebugInfo();
}, 1000);
}
function makeDraggable(element) {
var pos1 = 0, pos2 = 0, pos3 = 0, pos4 = 0;
element.onmousedown = dragMouseDown;
function dragMouseDown(e) {
e = e || window.event;
e.preventDefault();
pos3 = e.clientX;
pos4 = e.clientY;
document.onmouseup = closeDragElement;
document.onmousemove = elementDrag;
}
function elementDrag(e) {
e = e || window.event;
e.preventDefault();
pos1 = pos3 - e.clientX;
pos2 = pos4 - e.clientY;
pos3 = e.clientX;
pos4 = e.clientY;
// 计算新的位置
var newTop = element.offsetTop - pos2;
var newLeft = element.offsetLeft - pos1;
// 限制拖动范围,避免拖出屏幕
var minLeft = 0;
var minTop = 0;
var maxLeft = window.innerWidth - element.offsetWidth;
var maxTop = window.innerHeight - element.offsetHeight;
// 限制 left 和 top 的最小最大值
newLeft = Math.max(minLeft, Math.min(newLeft, maxLeft));
newTop = Math.max(minTop, Math.min(newTop, maxTop));
// 设置窗口的新位置,并保持固定宽度
element.style.top = newTop + "px";
element.style.left = newLeft + "px";
element.style.width = '300px'; // 强制宽度固定,避免拖动时缩小
}
function closeDragElement() {
document.onmouseup = null;
document.onmousemove = null;
}
}
function updateDebugInfo() {
var video = getVideo();
if (video) {
var debugInfo = shadow.getElementById('debugInfo');
var info = `