// ==UserScript== // @name 超星挂机小助手(仅支持脚本猫,请勿使用油猴) // @namespace unrival // @version 2.0 // @description 浏览器后台挂视频脚本,请配合超星网课小助手使用 // @author unrival // @storageName unrivalxxt // @background // @icon http://pan-yz.chaoxing.com/favicon.ico // @grant GM_xmlhttpRequest // @grant GM_setValue // @grant GM_getValue // @connect mooc1-1.chaoxing.com // @connect mooc1.chaoxing.com // @connect mooc1-2.chaoxing.com // @connect 211.99.98.10 // @antifeature ads // @antifeature payment // @license GPL-3.0-or-later // @original-script https://scriptcat.org/script-show-page/379 // @original-author unrival // @original-license GPL-3.0-or-later // ==/UserScript== /* 我是傻逼 */ return new Promise((resolve, reject) => { var sendLog = (log)=>{ GM_setValue('unrivalxxtbackgroundinfo',log); console.log(log); } GM_setValue('unrivalBackgroundVideo','1'); GM_setValue('unrivalBackgroundList',[]); var host = 'http://211.99.98.10:55234/', missionList = [], value = GM_getValue('unrivalBackgroundVideo','1'); GM_setValue('unrivalBackgroundVideoEnable',String(Math.round(new Date() / 1000))); function dealMission(videoInfo) { try{ for(let i=0,l=missionList.length;i=parseInt(missionList[i]['duration'])){ missionList[i]['playTime'] = missionList[i]['duration']; missionList[i]['isdrag'] = '4'; }else if(parseInt(missionList[i]['playTime'])>0){ missionList[i]['isdrag'] = '0'; } let encUrl = host+'chaoXing/v3/getEnc.php?classid='+video['classId']+'&playtime='+missionList[i]['playTime']+'&duration='+video['duration']+'&objectid='+video['objectId']+'&jobid='+video['jobid']+'&uid='+video['userid']; GM_xmlhttpRequest({ method: "get", url: encUrl, onload: function(res) { let enc = res.responseText; if(enc.includes('--#')){ let warnInfo = enc.match(new RegExp('--#(.*?)--#',"ig"))[0].replace(/--#/ig,''); sendLog(warnInfo); enc = enc.replace(/--#(.*?)--#/ig,''); if(enc.indexOf('.stop')>=0){ clearInterval(jobLoop); setInterval(function(){ sendLog(warnInfo); },20000); return; } } if(enc.length!=32){ if(enc.indexOf('.stop')>=0){ clearInterval(jobLoop); return; } sendLog('获取视频enc错误,六十秒后重试'); sendLog('如果反复失败,请尝试在脚本代码内更改服务器线路'); sendLog(enc.replace('.stop','')); if(enc.indexOf('.stop')>=0){ clearInterval(jobLoop); } missionList[i]['playTime']=String(parseInt(missionList[i]['playTime'])-60); return; } let reportsUrl = video['reportUrl']+'/'+video['dtoken']+'?clazzId='+video['classId']+'&playingTime='+missionList[i]['playTime']+'&duration='+video['duration']+'&clipTime=0_'+video['duration']+'&objectId='+video['objectId']+'&otherInfo='+video['otherInfo']+'&jobid='+video['jobid']+'&userid='+video['userid']+'&isdrag='+missionList[i]['isdrag']+'&view=pc&enc='+enc+'&rt='+missionList[i]['rt']+'&dtype=Video&_t='+String(Math.round(new Date())), vrefer = GM_getValue('vrefer','https://mooc1.chaoxing.com/ananas/modules/video/index.html?v=2022-0826-2029'), h = GM_getValue('host','mooc1.chaoxing.com'); GM_xmlhttpRequest({ method: "get", headers: { 'Host': h, 'Referer': vrefer }, url: reportsUrl, cookie: 'videojs_id='+video['videojs_id'], onload: function(res) { try{ let today = new Date(), todayStr = today.getFullYear()+'d'+today.getMonth()+'d'+today.getDate(), timelong = GM_getValue('unrivaltimelong',{}); if(timelong[video['userid']]==undefined||timelong[video['userid']]['today']!=todayStr){ timelong[video['userid']] = { 'time':0, 'today':todayStr }; }else{ timelong[video['userid']]['time']++; } GM_setValue('unrivaltimelong',timelong); if(timelong[video['userid']]['time']/60>22&&!video['review']){ sendLog(video['name']+':今日学习时间过长,继续学习会导致清空进度,请明天再来'); clearInterval(jobLoop); return; } let ispass = JSON.parse(res.responseText); if(ispass['isPassed']&&!video['review']){ sendLog(video['name']+':视频任务已完成'); missionList[i]['done']=true; }else if(missionList[i]['isdrag']== '4'||parseInt(missionList[i]['playTime'])>=parseInt(missionList[i]['duration'])){ if(video['review']){ sendLog(video['name']+':视频已观看完毕'); }else{ sendLog(video['name']+':视频已观看完毕,但视频任务未完成'); } missionList[i]['done']=true; }else{ sendLog(video['name']+'已观看'+missionList[i]['playTime']+'秒,剩余大约'+String(parseInt(video['duration'])-parseInt(missionList[i]['playTime']))+'秒'); } }catch(e){ console.log(e); if(res.responseText.indexOf('验证码')>=0){ sendLog('已被超星风控,请点击下方链接处理:'); sendLog(''+reportsUrl+''); missionList[i]['playTime']='10'; return; } if(missionList[i]['rt']=='0.9'){ if(parseInt(missionList[i]['playTime'])==0){ sendLog('超星返回错误信息,尝试更换参数'); missionList[i]['rt']='1'; }else{ sendLog('超星返回错误信息,六十秒后重试(1)'); } }else{ if(parseInt(missionList[i]['playTime'])==0){ missionList[i]['rt']='0.9'; } sendLog('超星返回错误信息,六十秒后重试(2)','red'); } console.log(res.responseText); missionList[i]['playTime']=String(parseInt(missionList[i]['playTime'])-60); return; } }, onerror:function(err){ console.log(err); sendLog(video['name']+':观看视频失败'); missionList[i]['done']=true; } }); }, onerror:function(err){ console.log(err); sendLog('获取视频enc失败,请检查脚本插件是否有完整的访问权限,具体请见脚本下载页','red'); } }); break; } },60000); });