// ==UserScript== // @name 不知名网课-学习通需要代刷请添加微信:bzm8866999/xiaobi8866999 // @namespace Muketool // @version 1.0.0 // @description // @match *://*.chaoxing.com/* // @connect greasyfork.org // @connect api.muketool.com // @connect api2.muketool.com // @connect static.muketool.com // @run-at document-end // @grant unsafeWindow // @grant GM_addStyle // @grant GM_setValue // @grant GM_getValue // @grant GM_getResourceText // @grant GM_xmlhttpRequest // @grant GM_setClipboard // @grant GM_getResourceURL // @antifeature ads // @require https://lf26-cdn-tos.bytecdntp.com/cdn/expire-1-M/jquery/3.6.0/jquery.min.js // @require https://static.muketool.com/scripts/cx/v2/js/Typr.min.js#md5=2ac9c9459368259ca63b0968c613e525 // @require https://static.muketool.com/scripts/cx/v2/js/Typr.U.min.js#md5=7fa27f07b2a19fbff3426bf5bfbaec2a // @resource CxSecretsFont https://static.muketool.com/scripts/cx/v2/fonts/cxsecret.json // @resource Layui https://lf3-cdn-tos.bytecdntp.com/cdn/expire-1-M/layui/2.6.8/css/layui.min.css // @resource LayuiIconFont-woff2 https://lf3-cdn-tos.bytecdntp.com/cdn/expire-1-M/layui/2.6.8/font/iconfont.woff2 // @resource LayuiIconFont-woff https://lf3-cdn-tos.bytecdntp.com/cdn/expire-1-M/layui/2.6.8/font/iconfont.woff // @resource LayuiIconFont-ttf https://lf3-cdn-tos.bytecdntp.com/cdn/expire-1-M/layui/2.6.8/font/iconfont.ttf // @license MIT // @original-script https://greasyfork.org/scripts/369625 // @original-author wyn665817 // @original-license MIT // @icon https://static.muketool.com/scripts/cx/v2/images/icon.png // ==/UserScript== /** * 学习通 */ // 当前小节 // 确保页面中存在至少一个激活的小节元素 const activeElement = $(".posCatalog_select.posCatalog_active"); if (activeElement.length) { // 先获取所有章节标题元素的父级(假设章节标题和小节同级) const chapterTitles = $(".posCatalog_select:has(.posCatalog_title)"); // 获取章节标题之外的所有小节元素 const substantiveSiblings = $(".posCatalog_select").not(chapterTitles); // 在实质性小节中找到当前活跃小节的索引 let unitCount = substantiveSiblings.index(activeElement); // jQuery 的 .index() 方法返回值是从0开始的,如果需要从1开始计数,可以加1 unitCount += 1; // 若找不到有效的小节同级元素,则设定默认值 if (!substantiveSiblings.length || unitCount === -1) { console.warn("未找到有效的.posCatalog_select同级元素!"); unitCount = -1; } // 将结果赋值到全局作用域 window.unitCount = unitCount; } else { console.error("未找到激活的小节元素!"); } // 获取小节数量 window.unit = $(".posCatalog_level span em").length; function main() { // 尝试点击视频按钮 document.querySelector('li[title="视频"]').click(); // 等待几秒后执行视频存在性检查和其他操作 setTimeout(() => { const frameObj = $("iframe").eq(0).contents().find("iframe.ans-insertvideo-online"); const videoNum = frameObj.length; if (videoNum > 0) { console.log("%c当前小节中包含 " + videoNum + " 个视频", "color:#FF7A38;font-size:18px"); var v_done = 0; // 添加事件处理程序 addEventListener("playdone", () => { v_done++; if (v_done > videoNum) { // 下一节 } else if (v_done < videoNum) { watchVideo(frameObj, v_done) } else { console.log("%c本小节视频播放完毕,等待跳转至下一小节...", "font-size:18px"); nextUnit(); } }); // 播放 watchVideo(frameObj, v_done); } else { if (window.unitCount < window.unit) { console.log("%c当前小节中无视频,6秒后将跳转至下一节", "font-size:18px"); nextUnit(); } else { console.log("%c好了好了,毕业了", "color:red;font-size:18px"); } } }, 3000);// 3000毫秒(即3秒)后执行 } function watchVideo(frameObj, v_done) { // 添加播放事件 var playDoneEvent = new Event("playdone"); // 获取播放对象 var v = undefined; v = frameObj.contents().eq(v_done).find("video#video_html5_api").get(0); window.a = v; // 设置倍速 try { v.playbackRate = 2; } catch (e) { console.error("倍速设置失败!此节可能有需要回复内容,不影响,跳至下一节。错误信息:" + e); nextUnit(); return; } // 播放 v.play(); console.log("%c正在 " + v.playbackRate + " 倍速播放第 " + (v_done + 1) + " 个视频", "font-size:18px"); // 循环获取播放进度 window.inter = setInterval(() => { v = window.a; if (v.currentTime >= v.duration) { dispatchEvent(playDoneEvent); clearInterval(window.inter); } if (v.paused) { v.play(); } }, 1000); } function nextUnit() { console.log("%c即将进入下一节...", "color:red;font-size:18px"); setTimeout(() => { $(document).scrollTop($(document).height() - $(window).height()); $("#prevNextFocusNext").click() $(".nextChapter").eq(0).click() $("#prevNextFocusNext").click() $(".nextChapter").eq(0).click() console.log("%c行了别看了,我知道你学会了,下一节", "color:red;font-size:18px");// (已经跳转" +(++window.unitCount)+"次)"); if (window.unitCount++ < window.unit) { setTimeout(() => main(), 10000) } }, 6000); } console.log("%c 欢迎使用本脚本,此科目有%c %d %c个小节,当前为 %c第%d小节 %c-chao", "color:#6dbcff", "color:red", window.unit, "color:#6dbcff", "color:red", window.unitCount, "font-size:8px"); main();