// ==UserScript== // @name 华为人才在线课程助手 (Huawei Talent Helper) - Safe // @namespace http://tampermonkey.net/ // @version 0.6 // @description 【极稳安全版】解决系统错误报错。禁用倍速,仅保留带随机延迟的自动连播。 // @author Antigravity // @match *://e.huawei.com/cn/talent/* // @match *://talent.shixizhi.huawei.com/* // @grant none // @run-at document-start // ==/UserScript== (function() { 'use strict'; /** * v0.6 安全版更新日志: * 1. 禁用倍速:将播放速度固定为 1.0x。报错极有可能是因为服务端校验了播放时长与实际进度的比例。 * 2. 随机延迟:视频结束后增加 5-15 秒的随机等待时间再跳转,模拟真实人类操作。 * 3. 极致精简:移除所有 UI 和不必要的检测,进一步降低脚本指纹。 */ const CONFIG = { autoNext: true, playbackSpeed: 1.0, // 降回原速以通过服务端校验 minDelay: 5000, // 最小延迟 5秒 maxDelay: 15000 // 最大延迟 15秒 }; console.log("[HuaweiSafe] 安全模式已启动。播放倍速: " + CONFIG.playbackSpeed); function safeRun() { const videos = document.querySelectorAll('video'); if (videos.length === 0) { console.log("[HuaweiSafe] 正在巡检:未发现视频元素,5秒后重试..."); } videos.forEach((video, index) => { const status = video.paused ? "已暂停" : "播放中"; const progress = ((video.currentTime / video.duration) * 100).toFixed(1); console.log(`[HuaweiSafe] 视频[${index}] 状态: ${status}, 进度: ${progress}%, 倍速: ${video.playbackRate}x`); // 确保播放速度正常 if (video.playbackRate !== CONFIG.playbackSpeed) { console.log(`[HuaweiSafe] 修正倍速: ${video.playbackRate}x -> ${CONFIG.playbackSpeed}x`); video.playbackRate = CONFIG.playbackSpeed; } // 自动播放 if (video.paused && !video.ended && video.readyState >= 2) { console.log("[HuaweiSafe] 检测到暂停,尝试自动播放..."); video.play().catch(() => {}); } // 自动连播 (带随机延迟) if (video.ended && CONFIG.autoNext && !video.dataset.safeJumped) { video.dataset.safeJumped = "true"; const delay = Math.floor(Math.random() * (CONFIG.maxDelay - CONFIG.minDelay) + CONFIG.minDelay); console.log(`%c[HuaweiSafe] 视频已播放完毕!将在 ${Math.round(delay/1000)} 秒后触发自动跳转...`, "color: #28a745; font-weight: bold;"); // 实时显示倒计时(可选) let remaining = Math.round(delay/1000); const timer = setInterval(() => { remaining--; if (remaining > 0) { console.log(`[HuaweiSafe] 跳转倒计时: ${remaining}s`); } else { clearInterval(timer); } }, 1000); setTimeout(doJump, delay); } }); // 随机化下一次检查时间 setTimeout(safeRun, 5000 + Math.random() * 2000); } function doJump() { const selectors = [ '.course-next-item', '.kltCourse-btn-next', '.vjs-next-button', 'div.next-chapter-btn' ]; let clicked = false; for (const selector of selectors) { const btn = document.querySelector(selector); if (btn && btn.offsetParent !== null) { btn.click(); clicked = true; break; } } if (!clicked) { const elements = document.querySelectorAll('span, button, div'); for (const el of elements) { if ((el.innerText.includes('下一讲') || el.innerText.includes('下一节')) && el.offsetParent !== null) { el.click(); clicked = true; break; } } } if (clicked) { console.log("[HuaweiSafe] 已自动跳转到下一节。"); } } // 延迟首次启动,确保页面加载稳定 setTimeout(safeRun, 5000); })();