// ==UserScript== // @name 超星学习通视频网课助手(QQ交流群:164902340) // @namespace VideoDetector // @version 1.2.0 // @description 精简的超星学习通视频任务点处理脚本 // @author VideoDetector // @match *://*.chaoxing.com/* // @run-at document-end // @grant unsafeWindow // @require https://lf26-cdn-tos.bytecdntp.com/cdn/expire-1-M/jquery/3.6.0/jquery.min.js // @license MIT // ==/UserScript== // 核心设置 var setting = { time: 3000, // 减少检测间隔,加快跳过速度 queue: 1, video: 1, // 只处理视频 jump: 1, work: 0, // 禁用作业处理,直接跳过 audio: 0, // 禁用音频处理,直接跳过 book: 0, // 禁用图书处理,直接跳过 docs: 0, // 禁用文档处理,直接跳过 autoSkip: 1 // 启用自动跳过非视频任务 }; var _self = unsafeWindow, url = location.pathname, top = _self; // 获取顶层窗口 try { while (top != _self.top) { top = top.parent.document ? top.parent : _self.top; if (top.location.pathname.endsWith('/mycourse/studentstudy')) break; } } catch (err) { top = _self; } // 初始化jQuery var $ = _self.jQuery || top.jQuery; // 设置任务点检测 setting.job = [':not(*)']; setting.video && setting.job.push('iframe[src*="/video/index.html"]'); setting.work && setting.job.push('iframe[src*="/work/index.html"]'); setting.audio && setting.job.push('iframe[src*="/audio/index.html"]'); setting.book && setting.job.push('iframe[src*="/innerbook/index.html"]'); setting.docs && setting.job.push('iframe[src*="/ppt/index.html"]', 'iframe[src*="/pdf/index.html"]'); // 主要逻辑 if (url.endsWith('/mycourse/studentstudy')) { console.log('视频检测脚本:在学习页面'); _self.checkMobileBrowerLearn = $.noop; checkToNext(); } else if (url.endsWith('/ananas/modules/video/index.html')) { console.log('视频检测脚本:检测到视频页面,开始处理'); passVideo(); } else if (url.endsWith('/work/index.html')) { console.log('视频检测脚本:检测到作业页面,直接跳过'); quickSkipTask('作业'); } else if (url.endsWith('/audio/index.html')) { console.log('视频检测脚本:检测到音频页面,直接跳过'); quickSkipTask('音频'); } else if (url.endsWith('/innerbook/index.html')) { console.log('视频检测脚本:检测到图书页面,直接跳过'); quickSkipTask('图书'); } else if ((url.endsWith('/ppt/index.html') || url.endsWith('/pdf/index.html'))) { console.log('视频检测脚本:检测到文档页面,直接跳过'); quickSkipTask('文档'); } else if (url.endsWith('/knowledge/cards')) { $ && checkToNext(); } // 视频处理主函数 function passVideo() { console.log('视频检测脚本:开始处理视频'); skipQuestion(); setTimeout(() => { let vd = $('video')[0]; if (vd) { console.log('视频检测脚本:找到视频元素,开始播放'); vd.volume = 0; // 静音 $('.vjs-big-play-button')[0] && $('.vjs-big-play-button')[0].click(); } }, 2000); } // 检查下一个任务 - 优化版 function checkToNext() { console.log('视频检测脚本:开始检查下一个任务'); var checkInterval = setInterval(function () { // 只检测视频任务 var $videoTasks = $('iframe[src*="/video/index.html"]', document).prevAll('.ans-job-icon'); var unfinishedVideoTasks = $videoTasks.parent(':not(.ans-job-finished)'); // 检测所有其他类型的任务并标记为需要跳过 var $otherTasks = $('iframe[src*="/work/index.html"], iframe[src*="/audio/index.html"], iframe[src*="/innerbook/index.html"], iframe[src*="/ppt/index.html"], iframe[src*="/pdf/index.html"]', document).prevAll('.ans-job-icon'); var unfinishedOtherTasks = $otherTasks.parent(':not(.ans-job-finished)'); // 如果有未完成的其他任务,优先跳过它们 if (unfinishedOtherTasks.length > 0) { console.log('视频检测脚本:发现非视频任务,准备跳过'); clearInterval(checkInterval); setTimeout(() => { // 点击第一个非视频任务来触发跳过 unfinishedOtherTasks.first().find('iframe').attr('src', function(i, src) { if (src) { window.open(src, '_self'); } }); }, 500); return; } // 如果只剩视频任务或没有任务,按原逻辑处理 if (unfinishedVideoTasks.length === 0 && setting.jump) { console.log('视频检测脚本:所有视频任务已完成,准备跳转下一节'); clearInterval(checkInterval); setTimeout(() => toNext(), 1000); } }, setting.time); } // 跳转到下一个任务 function toNext() { console.log('视频检测脚本:开始执行跳转逻辑'); try { let $ = _self.parent.$ || top.$ || window.parent.$ || unsafeWindow.$ || window.$; if (!$) { console.log('视频检测脚本:无法获取jQuery对象'); return; } // 查找"下一"相关的元素 var nextElements = $('span:contains("下一"), a:contains("下一"), .next, [title*="下一"]'); if (nextElements.length > 0) { nextElements.first().click(); return; } } catch (error) { console.log('视频检测脚本:跳转过程中出错:', error); } } // 跳过视频问题 function skipQuestion() { console.log('视频检测脚本:设置跳过视频问题'); const originOpen = XMLHttpRequest.prototype.open; XMLHttpRequest.prototype.open = function (_, url) { if (url.indexOf('richvideo/initdatawithviewerV2') > -1) { this.addEventListener("readystatechange", function () { if (this.readyState === 4) { Object.defineProperty(this, "responseText", { writable: true, }); this.responseText = JSON.stringify([]); console.log('视频检测脚本:已跳过视频问题'); } }); } originOpen.apply(this, arguments); }; } // 快速跳过任务函数 - 新增 function quickSkipTask(taskType) { console.log(`视频检测脚本:快速跳过${taskType}任务`); // 立即跳转,不等待 setTimeout(() => { if (setting.jump) { toNext(); console.log(`视频检测脚本:已快速跳过${taskType}任务`); } }, 200); // 极短延迟,几乎立即跳过 } // 自动跳过任务函数 - 保持原有但加快速度 function autoSkipTask(taskType) { console.log(`视频检测脚本:正在跳过${taskType}任务`); setTimeout(() => { if (setting.jump) { setTimeout(() => { toNext(); console.log(`视频检测脚本:已跳过${taskType}任务,正在跳转到下一个`); }, 300); // 减少延迟 } }, 100); // 减少延迟 }