// ==UserScript== // @name 江苏开放大学自动刷课脚本 // @namespace http://tampermonkey.net/ // @version 1.0 // @description 江苏开放大学相关视频自动学习自动看视频程序【可加速及自动下一页】,做题/实验实践/合作/教务处理等建议QQ群1:756253160 二群:949193546联系群主! // @author 一心向善 // @match http://xuexi.jsou.cn/jxpt-web/student/courseuser/courseVersionId=* // @match http://xuexi.jsou.cn/jxpt-web/student/activity/display?courseVersionId=* // @match http://xuexi.jsou.cn/jxpt-web/student/newHomework/showHomeworkByStatus?courseVersionId=* // @grant unsafeWindow // @grant GM_setValue // @grant GM_getValue // @license MIT // ==/UserScript== (function() { 'use strict'; var manualSelectRunning = false; var autoJumpRunning = false; var autoPlayEnabled = GM_getValue('autoPlayEnabled', true); var autoNextEnabled = GM_getValue('autoNextEnabled', true); var speedValue = GM_getValue('speedValue', 1.0); var manualSelectButton = null; var autoJumpButton = null; // 自动播放 function autoPlayVideo() { if (!autoPlayEnabled) return; setInterval(() => { let video = document.querySelector('video'); if (video && video.paused) video.play(); }, 1000); } // 倍速 function setSpeed(speed) { speedValue = speed; GM_setValue('speedValue', speed); let video = document.querySelector('video'); if (video) video.playbackRate = speed; } // 自动下一页 function autoNextPage() { if (!autoNextEnabled) return; setInterval(() => { let video = document.querySelector('video'); if (video && video.ended && autoJumpRunning) { setTimeout(() => { window.history.go(0); }, 1500); } }, 2000); } // 发送时长 function AddTime(seconds) { var total = Math.ceil(seconds / 30); for (var i = 0; i < total; i++) sendHeartBeatAjax(); } // 停止全部 function stopAll() { manualSelectRunning = false; autoJumpRunning = false; GM_setValue('manualSelectRunning', false); GM_setValue('autoJumpRunning', false); if (manualSelectButton) { manualSelectButton.textContent = '启动手动选课'; manualSelectButton.style.backgroundColor = '#FF5722'; } if (autoJumpButton) { autoJumpButton.textContent = '开始自动跳转'; autoJumpButton.style.backgroundColor = '#9C27B0'; } } // 手动选课计时 async function startHeartbeat(minMinutes, maxMinutes) { var activityId = null; function get() { if (typeof units !== 'undefined') { for (let u of units) { for (let a of u.activitys) { if (a.activityId) { activityId = a.activityId; return; } } } } else { activityId = new URLSearchParams(location.search).get('activityId'); } } get(); await new Promise(r=>setTimeout(r,1000)); if (!activityId || !GM_getValue('manualSelectRunning')) return; var min = Math.ceil(minMinutes*60/30); var max = Math.floor(maxMinutes*60/30); var total = (Date.now() % (max-min+1)) + min; for (var i=0;isetTimeout(r,150)); } } function ManualSelectAuto(min, max) { if (manualSelectRunning) { stopAll(); alert('已停止'); return; } manualSelectRunning = true; GM_setValue('manualSelectRunning', true); manualSelectButton.textContent = '停止手动选课'; manualSelectButton.style.backgroundColor = '#f44336'; startHeartbeat(min, max); } // 自动跳转 function AllCourseAuto() { if (autoJumpRunning) { stopAll(); alert('已停止'); return; } var list = []; var ver = new URLSearchParams(location.search).get('courseVersionId'); if (typeof units !== 'undefined') { for (let u of units) { for (let a of u.activitys) { if (!a.activityId) continue; let name = a.activityName||''; if (name.includes('作业')||name.includes('讲评')||name.includes('考核')||name.includes('破冰')) continue; list.push({id:a.activityId, url:'http://xuexi.jsou.cn/jxpt-web/student/activity/display?courseVersionId='+ver+'&activityId='+a.activityId}); } } } if (list.length===0) { alert('未找到课程'); return; } autoJumpRunning = true; GM_setValue('autoJumpRunning', true); autoJumpButton.textContent = '停止自动跳转'; autoJumpButton.style.backgroundColor = '#f44336'; var now = new URLSearch(location.search).get('activityId'); var idx = list.findIndex(x=>x.id==now) +1; if (idx>=list.length) { alert('已全部完成'); stopAll(); return; } setTimeout(()=>location.href=list[idx].url, GM_getValue('jumpDelay',2)*1000); } // 面板注入 function InjectPanel() { let panel = document.createElement('div'); panel.style.cssText = ` position:fixed; left:20px; top:20px; z-index:99999; background:#fff; border:1px solid #444; border-radius:8px; width:360px; padding:12px; box-shadow:0 0 10px rgba(0,0,0,0.2); font-size:14px; line-height:1.5; `; // 拖拽 let drag = false,ox=0,oy=0; panel.onmousedown = e=>{ drag=true; ox=e.clientX-panel.offsetLeft; oy=e.clientY-panel.offsetTop; }; document.onmousemove = e=>{ if(!drag)return; panel.style.left=e.clientX-ox+'px'; panel.style.top=e.clientY-oy+'px'; }; document.onmouseup = ()=>drag=false; let title = document.createElement('div'); title.innerText = '🎯 全自动刷课面板'; title.style.cssText = 'font-weight:bold; margin-bottom:10px; text-align:center; font-size:16px;'; panel.appendChild(title); // 1. 手动加时长 let timeGroup = document.createElement('div'); timeGroup.innerHTML = `📊 手动增加时长`; timeGroup.style.marginBottom = '8px'; panel.appendChild(timeGroup); let times = [ {t:'+30秒',s:30,c:'#2196F3'}, {t:'+1分钟',s:60,c:'#4CAF50'}, {t:'+5分钟',s:300,c:'#FF9800'}, {t:'+10分钟',s:600,c:'#E91E63'} ]; let timeBar = document.createElement('div'); timeBar.style.display = 'flex'; timeBar.style.gap = '4px'; timeBar.style.marginBottom = '10px'; times.forEach(item=>{ let b = document.createElement('button'); b.innerText = item.t; b.style.cssText = `padding:4px 8px; background:${item.c}; color:#fff; border:none; border-radius:4px; flex:1;`; b.onclick = ()=>AddTime(item.s); timeBar.appendChild(b); }); panel.appendChild(timeBar); // 2. 自动计时 let autoTime = document.createElement('div'); autoTime.style.display = 'flex'; autoTime.style.gap = '4px'; autoTime.style.marginBottom = '10px'; let minI = document.createElement('input'); minI.type = 'number'; minI.value = GM_getValue('manualMin',8); minI.style.width = '45px'; let maxI = document.createElement('input'); maxI.type = 'number'; maxI.value = GM_getValue('manualMax',10); maxI.style.width = '45px'; let startBtn = document.createElement('button'); startBtn.innerText = '启动自动计时'; startBtn.style.cssText = 'background:#FF5722; color:#fff; border:none; padding:4px 8px; border-radius:4px; flex:1;'; manualSelectButton = startBtn; startBtn.onclick = ()=>{ GM_setValue('manualMin',~~minI.value||8); GM_setValue('manualMax',~~maxI.value||10); ManualSelectAuto(~~minI.value||8, ~~maxI.value||10); }; autoTime.append(document.createTextNode('时长:'), minI, document.createTextNode('~'), maxI, document.createTextNode('分钟'), startBtn); panel.appendChild(autoTime); // 3. 自动跳转 let jumpBar = document.createElement('div'); jumpBar.style.display = 'flex'; jumpBar.style.gap = '4px'; jumpBar.style.marginBottom = '10px'; let delayI = document.createElement('input'); delayI.type = 'number'; delayI.value = GM_getValue('jumpDelay',2); delayI.style.width = '40px'; let jumpBtn = document.createElement('button'); jumpBtn.innerText = '开始自动跳转'; jumpBtn.style.cssText = 'background:#9C27B0; color:#fff; border:none; padding:4px 8px; border-radius:4px; flex:1;'; autoJumpButton = jumpBtn; jumpBtn.onclick = ()=>{ GM_setValue('jumpDelay',~~delayI.value||2); AllCourseAuto(); }; jumpBar.append(document.createTextNode('延迟:'), delayI, document.createTextNode('秒'), jumpBtn); panel.appendChild(jumpBar); // 4. 功能开关 let swTitle = document.createElement('div'); swTitle.innerHTML = `⚙️ 功能开关`; swTitle.style.marginTop = '10px'; swTitle.style.marginBottom = '6px'; panel.appendChild(swTitle); let sw1 = document.createElement('label'); sw1.style.display = 'block'; sw1.innerHTML = ` 🔘 自动播放视频`; let c1 = sw1.querySelector('input'); c1.onchange = ()=>{ autoPlayEnabled=c1.checked; GM_setValue('autoPlayEnabled',c1.checked); }; panel.appendChild(sw1); let sw2 = document.createElement('label'); sw2.style.display = 'block'; sw2.innerHTML = ` 🔘 播放完自动下一页`; let c2 = sw2.querySelector('input'); c2.onchange = ()=>{ autoNextEnabled=c2.checked; GM_setValue('autoNextEnabled',c2.checked); }; panel.appendChild(sw2); // 5. 倍速 let speedLine = document.createElement('div'); speedLine.style.marginTop = '6px'; speedLine.innerHTML = `🚀 视频倍速:`; [0.5,1.0,1.25,1.5,2.0].forEach(s=>{ let btn = document.createElement('button'); btn.innerText = s+'x'; btn.style.cssText = 'margin-left:4px; padding:2px 6px; border:1px solid #ccc; border-radius:3px;'; btn.onclick = ()=>setSpeed(s); speedLine.appendChild(btn); }); panel.appendChild(speedLine); // 分割线 let hr = document.createElement('div'); hr.style.cssText = 'border-top:1px solid #eee; margin:12px 0;'; panel.appendChild(hr); // 说明文字 let info = document.createElement('div'); info.style.fontSize = '12px'; info.style.color = '#333'; info.style.lineHeight = '1.6'; info.innerHTML = ` 基础功能:
1、播放完毕自动下一页
2、倍数可自由调节,建议最大调节到2倍即可;
3、作业及线上实验实践、文件题、主观题、简答题等进群:949193546联系群主
4、散单、批量单、合作、各类教务处理进QQ一群:756253160 二群:949193546联系群主!
`; panel.appendChild(info); document.body.appendChild(panel); } function MainRun() { if (location.href.includes('display')) { InjectPanel(); autoPlayVideo(); autoNextPage(); setSpeed(speedValue); if (GM_getValue('manualSelectRunning')) { manualSelectRunning = true; manualSelectButton.textContent = '停止手动选课'; manualSelectButton.style.backgroundColor = '#f44336'; startHeartbeat(GM_getValue('manualMin',8), GM_getValue('manualMax',10)); } if (GM_getValue('autoJumpRunning')) { autoJumpRunning = true; autoJumpButton.textContent = '停止自动跳转'; autoJumpButton.style.backgroundColor = '#f44336'; } } } MainRun(); })();