# stu.5zk.com **Repository Path**: luo-99/stu.5zk.com ## Basic Information - **Project Name**: stu.5zk.com - **Description**: 汕头大学刷网课脚本 - **Primary Language**: JavaScript - **License**: GPL-3.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-03-01 - **Last Updated**: 2025-03-01 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 脚本说明 文档已经说的很清楚了,看不懂的就别搞了,老老实实刷课吧,报计算机专业连这么简单的都看不懂? 再不懂就去问AI,全部复制给AI让AI教你,或者百度,B站,看类似使用篡改猴的视频,脚本都给你了 想自己改写脚本就B站看一下 html 和 javaScript 相关基础, 再借助AI问怎么写篡改猴脚本就行 ## 环境安装 1 edge浏览器最新版本 ```shell https://www.microsoft.com/zh-cn/edge/download?form=MA13FJ ``` 2 浏览器安装插件篡改猴 ```shell # 安装地址 https://microsoftedge.microsoft.com/addons/detail/%E7%AF%A1%E6%94%B9%E7%8C%B4/iikmkjmpaadaobahmlepeloendndfphd # 启用篡改猴插件,同时打开"开发人员模式" edge://extensions/ ``` ![image-20250301214827569](img/image-20250301214827569.png) ## 使用说明 3 导入脚本 ```js 0练习测评显答案开启复制粘贴.js // 不能看答案了,网站升级了只有答题后才返回答案,所以现在只能练习和测评的时用于简答题答案粘贴,简答题无法粘贴立即刷新网页迅速粘贴,无需修改此脚本 // 使用微信或者qq截图可以提取文本内容,再复制题目问AI就能拿到答案了 1汕头大学-登录页面自动登录_需要填写账号密码.js.js // 需要修改此脚本内容,输入自己的登录学习账号密码,防止网站掉登录自动登录回去刷课 2汕头大学-选课页自动进入未学习100的课.js // 课程页面自动选择未刷完的课程学习,无需修改此脚本 3汕头大学-声音-课程播放页面自动选择未完成的课程.js // 无需修改脚本,但是浏览器设置要添加网站 // 需要浏览器开放权限 edge://settings/content/mediaAutoplay 如下图 // 添加 https://stu.5zk.com.cn 网站自动播放媒体声音 4跳练习自动返回刷课.js // 防止刷完一个章节就跳练习,不做练习继续返回刷课,无需修改此脚本 ``` ![image-20250301215628079](img/image-20250301215628079.png) 把脚本加入篡改猴,并启用 ![image-20250301220533546](img/image-20250301220533546.png) ## 脚本内容 ### 0练习测评显答案开启复制粘贴v2 ```js // ==UserScript== // @name 0练习测评显答案开启复制粘贴v2 // @namespace http://tampermonkey.net/ // @version 1.0 // @description 0练习测评显答案开启复制粘贴v2 // @author Luo1999 // @match https://stu.5zk.com.cn/zk8exam/wiki_exam_zy.php* // @match https://stu.5zk.com.cn/zk8exam/wiki_exam_cy.php* // @grant none // @run-at document-start // ==/UserScript== // 简答题答题不能粘贴刷新浏览器立即粘贴 (async function () { 'use strict'; function sleep(ms) { return new Promise(resolve => setTimeout(resolve, ms)); } try { let answer = document.getElementById("resolve"); while (!answer){ answer = document.getElementById("resolve"); await sleep(200); } answer.style.display = '' //let p = document.querySelectorAll("#resolve p")[0]; // const innerText = p.innerText; document.oncopy = null; document.onpaste = null; document.oncut = null; document.onselectstart = null; // 开启复制粘贴 // p.style.pointerEvents = 'none'; //console.log(innerText); } catch (e) { console.error('获取答案出现错误: ', e) } })(); ``` ### 1汕头大学-登录页面自动登录_需要填写账号密码 ```js // ==UserScript== // @name 1汕头大学-登录页面自动登录_需要填写账号密码 // @namespace http://tampermonkey.net/ // @version 0.1 // @description 自动登录,默认先选好学生和记住账号密码才能用 // @author Luo1999 // @match https://stu.5zk.com.cn/zk8exam/login.php* // @grant none // @run-at document-idle // ==/UserScript== (async function () { 'use strict'; window.onload = async function () { try { // 睡眠 function sleep(ms) { return new Promise(resolve => setTimeout(resolve, ms)); } /* 示例: 必须填对,(不填也可以除非你浏览器记录并自动帮你填了) const user = '245310534162' const pwd = '123148' 这里是注释,填下面的 */ // TODO 你的用户密码 const user = '你的账号' const pwd = '你的密码' if (user){ document.getElementById('admin_name').value = user; document.getElementById('admin_password').value = pwd; } // 选中学生状态 document.getElementById('example-inline-radio1').checked = true; let size = 0; while (true) { document.querySelector('button[type="submit"]').click(); size = size +1; await sleep(5000); if (size>10){ // 刷新浏览器 location.reload(true); return; } } }catch (e){ console.error('出现错误,从来...',e) await sleep(3000); window.location.href = "https://stu.5zk.com.cn/zk8exam/login.php"; // 刷新浏览器 location.reload(true); } } })(); ``` ### 2汕头大学-选课页自动进入未学习100的课 ```js // ==UserScript== // @name 2汕头大学-选课页自动进入未学习100的课 // @namespace http://tampermonkey.net/ // @version 0.1 // @description 选课页自动进入未学习100的课 // @author Luo1999 // @match https://stu.5zk.com.cn/zk8exam/mycourse.php* // @grant none // @run-at document-idle // ==/UserScript== (async function () { 'use strict'; window.onload = async function () { // 睡眠 function sleep(ms) { return new Promise(resolve => setTimeout(resolve, ms)); } try { while (true) { // while (true) { // https://stu.5zk.com.cn/zk8exam/jp_wiki_study.php?kcdm=BKS002 // document.querySelector('button[type="submit"]').click(); // await sleep(10000); // 获取所有 元素 const allTrs = document.querySelectorAll('tr'); let arr = [] allTrs.forEach(tr => { // 获取当前 中的所有 元素 const tds = tr.querySelectorAll('td'); console.log('课程编号', tds[0].innerText) // 检查是否存在第5个 if (tds.length >= 9) { // 获取第5个 中的 标签 const aTag = tds[4].querySelector('a'); const aTag5 = tds[5].querySelector('a'); const divs = tds[8].querySelectorAll('div'); if (aTag && aTag5) { // 包含学习 if (aTag.textContent.trim().includes('学习') && aTag5.textContent.trim().includes('练习')) { if (divs.length >= 7) { // 不为100%进度 if (divs[7].innerText.trim() !== '100') { arr.push(tds[0].innerText); console.log("未学习完成的节点", aTag, "进度: ", divs[7].innerText.trim()) } } } } } }); // 学习地址 let url = 'https://stu.5zk.com.cn/zk8exam/jp_wiki_study.php?kcdm='; if (arr.length>0){ console.log("3秒后进入学习....") await sleep(3000); // 课程编号,进入学习 window.location.href = url + arr[0]; await sleep(10000); console.log('睡眠10秒结束,准备强制刷新,这个执行就是有bug') // 10秒后刷新浏览器 location.reload(true); } } }catch (e){ console.error('出现错误,从来...',e) await sleep(3000); window.location.href = "https://stu.5zk.com.cn/zk8exam/mycourse.php"; // 刷新浏览器 location.reload(true); } } })(); ``` ### 3汕头大学-声音-课程播放页面自动选择未完成的课程 ```js // ==UserScript== // @name 3汕头大学-声音-课程播放页面自动选择未完成的课程 // @namespace http://tampermonkey.net/ // @version 0.1 // @description 课程播放页面自动选择未完成的课程 // @author Luo1999 // @match https://stu.5zk.com.cn/zk8exam/jp_wiki_study.php* // @grant none // @run-at document-start // ==/UserScript== /* 插件地址 https://microsoftedge.microsoft.com/addons/detail/%E7%AF%A1%E6%94%B9%E7%8C%B4%E6%B5%8B%E8%AF%95%E7%89%88/fcmfnpggmnlmfebfghbfnillijihnkoh 浏览器窗口遮挡 设置为 disabled edge://flags/#calculate-native-win-occlusion chrome://flags/#calculate-native-win-occlusion */ (async function () { 'use strict'; /** * 页面加载完成执行的代码 * @returns {Promise} */ async function windowOnload() { console.log('页面加载完成111') // 睡眠 function sleep(ms) { return new Promise(resolve => setTimeout(resolve, ms)); } // 跳转到视频总时长 function toEnd(video, sikp) { video.currentTime = parseFloat(sikp); } // 重写 alert 函数,防止弹窗导致js不执行 function rewrite() { var _alert = window.alert window.alert = function () { return true; } // 移除事件,让可以后台播放 window.onblur = null; $(window).off('blur'); } try { rewrite(); // 每次循环执行一下,防止浏览器播放下个章节时 alter函数重置 // 获取当前播放标题 const title = document.querySelector(".block-title div"); // 当前播放器播放按钮 let play = document.querySelector('button[title="播放"]'); // 中间按钮 console.log("play状态1: ", play, new Date().toLocaleTimeString()) while (!play) { play = document.getElementsByClassName("bigplaybtn j-bigplaybtn")[0]; // play = document.querySelector('a.bigplaybtn.j-bigplaybtn.z-show'); console.log("play状态2: ", play, new Date().toLocaleTimeString()) // 睡眠一段时间 await sleep(1000); } // 当前播放器元素 const video = document.getElementsByTagName("video")[0]; video.muted = true; // 播放器静音,才能开启自动播放 // 获取播放列表a标签 const aLi = document.querySelectorAll("ul.list.list-activity li"); const aList = []; aLi.forEach(function (item) { const a = item.querySelector('a'); const div = item.querySelectorAll('div')[1]; const time = div.innerText.match(/\((.*?)\)/); const schedule = time[1].split("/"); // 进度 console.log(a.innerText, schedule[0] === schedule[1] ? "已完成" : "未完成", '进度', schedule[0], '/', schedule[1]) a.setAttribute('ok', schedule[0] === schedule[1] ? "1" : "0"); aList.push(a); // 未完成直接跳 if (!schedule[0] === schedule[1]) { console.error('排查bug') console.log(!schedule[0] === schedule[1]) console.log(a) console.log(a.href) window.location.href = a.href; } }); // 只能创建一个定时 let one = true; let lastTime = 0; // 视频进度 for (let i = 0; i < aList.length; i++) { const a = aList[i]; // 每个课的a标签 // 先在a中找到当前章节 if (title.innerText.includes(a.innerText.replace(/\n/g, ""))) { // var 变量 nextUrl = 'https://stu.5zk.com.cn/zk8exam/mycourse.php'; if (i === aList.length - 1) { console.log('最后一节') } else { try { nextUrl = aList[i + 1].href; if (!nextUrl) { nextUrl = 'https://stu.5zk.com.cn/zk8exam/mycourse.php'; } } catch (e) { console.log('当前索引:', i + 1, '课程数:', aList.length) nextUrl = 'https://stu.5zk.com.cn/zk8exam/mycourse.php'; } } console.log('当前播放章节: ', a.innerText, "\n当前地址: ", a.href, "\n下一节地址:", nextUrl); //====================== 去除练习 ========================== // 总进度 const max_jindu = document.getElementById("max_jindu"); // 当前进度 const cur_jindu = document.getElementById("cur_jindu"); let currCount = 0; const maxCount = 10; // 10次失败重新加载本页面 // 等待当前播放章节播放完成 while (true) { // 已经学习完 const ok = a.getAttribute('ok'); // console.log(a.innerText, ' 是否完成',ok==='1'?'已完成':'未完成'); if (ok === '1' || maxCount < currCount) { //本讲无习题时,弹出提示 console.log("本章学习已完成,本章不需要进行章节练习,请继续学习下一章!") video.pause(); if (i >= aList.length) { console.log("本课程学习完成...准备返回上一级") await sleep(3000); window.location.href = "https://stu.5zk.com.cn/zk8exam/mycourse.php"; return; } // 进入下一个页面 window.location.href = nextUrl; return; } else { // 没看完, 判断当前播放状态 if (video.paused) { toEnd(video, max_jindu.value - 3); // 设置当前进度 cur_jindu.value = max_jindu.value - 3; // 设置当前进度 // currCount++; // 页面获取焦点 // document.body.focus(); // 播放视频 let sizeC = 0; while (video.readyState <= 1) { await sleep(1000); sizeC = sizeC + 1; console.log("播放器未就绪,请稍后: ", video.readyState, new Date().toLocaleTimeString()); if (sizeC > 60) { console.log('超过60秒,刷新页面....') // 进入下一个页面 window.location.href = aList[i].href; // 10秒后刷新浏览器 location.reload(true); return; } } play.click(); // 防止不生效,触发一下自动播放按钮 // 还是没播放就播放一下 if (video.paused) { video.muted = false; // 自动播放 video.play().catch(function (error) { console.error('video自动播放失败: ', error); console.log("再次试着播放", new Date().toLocaleTimeString()); }); } if (one){ one = false; setInterval(() => { let currentTime = video.currentTime; if (currentTime === lastTime) { console.error('视频卡住,刷新浏览器...') // 进入下一个页面 window.location.href = aList[i].href; // 10秒后刷新浏览器 location.reload(true); } else { console.info('视频正常,10秒检测触发...') lastTime = currentTime; } }, 10000); // 每10秒检测一次 video.addEventListener('error', async () => { console.error('视频播放出错,刷新浏览器修正...') await sleep(3000); window.location.href = aList[i].href; location.reload(true); }); } } else { if (video.muted) { video.muted = false; } console.log('---------------------------------------------\n当前播放章节: ', a.innerText, "当前地址: ", a.href, "\n下一节地址:", nextUrl, "\n时间: ", new Date().toLocaleTimeString()); } // 睡眠一段时间 await sleep(3000); } } } else { console.log('定位当前播放章节中.......', a.innerText, "播放器状态: ", video.readyState, "地址: ", a.href); } } } catch (e) { console.error('出现错误,从来...', e) await sleep(10000); window.location.href = "https://stu.5zk.com.cn/zk8exam/mycourse.php"; // 刷新浏览器 location.reload(true); } } try { // 使用 MutationObserver 来监听 DOM 变化 const observer = new MutationObserver(function (mutationsList) { for (const mutation of mutationsList) { if (mutation.type === 'childList') { mutation.addedNodes.forEach(node => { if (node.tagName === 'SCRIPT') { // 找到