// ==UserScript== // @name 腾讯课堂、超星自动签到(新测试版) // @description 腾讯课堂、超星自动签到 // @namespace CX&TXKT_auto_sign // @author 涛之雨 // @version 0.2.9 // @grant GM_getValue // @grant GM_setValue // @grant GM_registerMenuCommand // @grant GM_addStyle // @run-at document-start // @require https://libs.baidu.com/jquery/2.1.4/jquery.min.js // @match *://ke.qq.com/course/* // @match *://ke.qq.com/webcourse* // @match *://mobilelearn.chaoxing.com/widget/pcpick/stu/index* // @match *://*.chaoxing.com/visit/interaction* // @match *://i.mooc.chaoxing.com/* // @license GPL-3.0-only // @icon https://i.loli.net/2020/03/04/D3h1iWSFeyc8AKG.png // @home-url https://greasyfork.org/zh-CN/scripts/401115 // @downloadURL none // ==/UserScript== /* * 更新: * V0.2.9 * 增加对于部分页内播放器重定向到全屏播放的重定向按钮(暂未考虑自动重定向) * (测试功能)回复复读机,指定连续x条回复,自动回复, * 增加回复黑名单(防止重复回复) * 改善页面的动画,看起来更流畅,更美观 * 修复对于签到、辅助等连续成功后数字不增加的bug * 还有若干。。。想不起来了 * * V0.2.8 * 辅助作答后播报和log中添加选择的选项 * 修复了部分注释的历史遗留问题 * * V0.2.7 * 修复签到结束后不继续监视的bug * * V0.2.6 * 修复签到等待时间小于1秒无法语音播报的bug * * V0.2.5 * 修复了腾讯课堂监视配置读取错误的bug * 修复选择题的点击bug * 修复选择题点击后关闭窗口的bug * 修复多次调用点击事件的bug * 注:尚在测试中,请勿过度依赖本功能(脚本) * * V0.2.4 * 修复了选择等待时间错误 * 修复了TTS发音部分参数错误 * 修复了插件更新设置后会多个线程同时执行的BUG * 如果有懂一点js,会js的朋友如果老师有发起选择题的时候给个样本或是解决方案呗 * 我们这里都要结束了,都没有老师再发起选择题。。。 * 此外还更新了啥我忘了。。。 * * V0.2.3 * 修复:腾讯课堂无法自动选择(好不容易老师发起一次我还错过了) * 修复更改设置后许刷新才生效的bug * 删除会引起错误的调试代码(对于脚本无影响) * * V0.2.2 * 【重大更新】修复严重bug(凌晨两点果然脑子就不好了。。。。) * 增加了双击悬浮球回复默认设置 * * V0.2.1 * 【重大更新】增加插件设置界面,便于管理 * 【重大更新】增加TTS语音播报功能 * (默认开启,有需要请到支持的页面配置) * 剩余优化时间的显示 * 优化算法和数据处理,增加插件的稳定性 * * V0.1.2 * 修复了已知bug(选择题功能尚未测试) * * V0.1.1 * 修复了签到子页面无法自动刷新的bug * * V0.1.0 * 删掉了我垃圾小站的图标(虽然用广告拦截器一拦截就好了。。。),去掉68行无用代码。。。 * 把自定义参数放到开头,方便用户进行自定义修改(没有基础请勿修改其他部分!) * * 腾讯课堂部分: * 对签到适配更加精准,不会误点 * 增加选择题的随机选择功能 * (未经测试。。。。开启请慎重!) * (严重的bug倒不会至于。主要可能不是预期效果) * * 超星部分: * 对课程信息进行重新分组 * 对签到的流程进行优化 * 增加签到成功和特殊的签到类型的判断及弹窗提醒,下个版本考虑增加对于微信的对接(太麻烦,懒得,此外本人不看微信。。。。) * */ //个人小站:https://taozhiyu.gitee.io(虽然啥都没有。。。) //吾爱主页:https://www.52pojie.cn/home.php?mod=space&uid=879080 //CSDN主页:https://blog.csdn.net/weixin_44352049(虽然也是啥都没有) //使用说明:https://greasyfork.org/zh-CN/scripts/401115 //吾爱说明:https://www.52pojie.cn/thread-1163575-1-1.html //CSDN说明:https://blog.csdn.net/weixin_44352049/article/details/106031114 //未做混淆或加密, //按F12打开console即可看到日志 //懂js可以自行DIY (function() { 'use strict'; window.getAbsoluteLeft=function (o) { var oLeft = o.offsetLeft; while(o.offsetParent!==null) { var oParent = o.offsetParent; oLeft += oParent.offsetLeft; o = oParent; } return oLeft; }; //获取控件上绝对位置 window.getAbsoluteTop=function (o) { var oTop = o.offsetTop; while(o.offsetParent!==null) { var oParent = o.offsetParent; oTop += oParent.offsetTop; o = oParent; } return oTop; }; if(location.href.match(/ke.qq.com\/course/)){ var url=""; $(document).ready(function () { var Container = document.createElement('a'); Container.id = "modle302"; Container.title='点击重定向'; Container.innerHTML='点击重定向'; Container.style="width: 20px;height: 20px;background: red;color: white;border: blue double;cursor: pointer;"; $(".course-title > h3")[0].appendChild(Container); $("#modle302").click(function(){ if(url!==""){ location.href=url; }else{ alert("链接尚未加载完成,请稍后重试!"); } }); setInterval(function () { var ifr=document.querySelector("#js-study-video"); if (ifr) { try{ var cid=ifr.src.toString().match(/cid=\d+/); var tid=ifr.src.toString().match(/term_id=\d+/); var taid=ifr.src.toString().match(/taid=\d+/); if(!(cid&&tid&&taid)){ url="https://ke.qq.com/webcourse/index.html#cid="+ cid[0].match(/\d+/)[0]+ "&term_id="+ tid[0].match(/\d+/)[0]+ "&taid="+ taid[0].match(/\d+/)[0]; } }catch(e){ console.error("未知错误!\n请复制错误信息提交反馈====>>\n\n",e); } } }, 500); }); return; } let AutoSignConfig = {}; let DefaultConfig = { TTS_IsOpen:true, TTS_Volce:5, TTS_Speed:7, CX_IsOpen:true, CX_WaitingTime:30, CX_MaxWaitingCount:20, TXKT_Repeater_IsOpen:false, TXKT_Repeater_WaitingTime:1000, TXKT_Repeater_MaxWaitingCount:7, TXKT_Signing_WaitingTime:5000, TXKT_Ansering_IsOpen:false, TXKT_Ansering_IsRandom:true, TXKT_Ansering_WaitingTime:-20 }; Promise.all([GM_getValue("CXAndTXKTConfig")]).then(function (data) { if (data[0] !== undefined) { try{ AutoSignConfig = JSON.parse(data[0]); }catch (e) { AutoSignConfig = data[0]; } } else { AutoSignConfig = DefaultConfig; } for(var key in DefaultConfig){ if(typeof(AutoSignConfig[key]) == "undefined"){ AutoSignConfig[key] = DefaultConfig[key]; } } // 初始化完成之后才能调用正常函数 MainFunction(); }).catch(function (except) { console.log(except); }); window.T2S=function (TXT){ if(!AutoSignConfig.TTS_IsOpen){ return; } if(TXT===undefined){ TXT="我有参数呢,播报的内容您还没填呢。填写后才能读出你想要的文字呢,亲!"; } var tmp = document.createElement("div"); tmp.innerHTML = ''; tmp.id="taoSignAudioTEST"; document.getElementsByTagName("body")[0].append(tmp); tmp=document.getElementById('taoSignAudio'); if(tmp){ tmp.src = "http://tts.baidu.com/text2audio?cuid=baiduid&per=4&vol="+AutoSignConfig.TTS_Volce+"&pit=6&lan=zh&spd="+AutoSignConfig.TTS_Speed+"&ctp=1&pdt=311&ie=UTF-8&tex="+TXT; }else{ tmp = document.createElement("audio"); tmp.id = 'taoSignAudio'; tmp.src = "http://tts.baidu.com/text2audio?cuid=baiduid&per=4&vol="+AutoSignConfig.TTS_Volce+"&pit=6&lan=zh&spd="+AutoSignConfig.TTS_Speed+"&ctp=1&pdt=311&ie=UTF-8&tex="+TXT; document.getElementsByTagName("body")[0].append(tmp); } try{ document.getElementById('taoSignAudio').play(); }catch(e){ console.log("error:==>"+e);} document.getElementById('taoSignAudioTEST').remove(); }; GM_registerMenuCommand('我找不到插件设置窗口!告诉我在哪里', function () { $("#AutoSignSettingIcon").css("top",0); if($("#preloading")){ $("#preloading").css("filter","blur(10px)"); } $("#react-body").css("filter","blur(10px)"); setTimeout(function(){ function tmp(){ $("#AutoSignSettingIcon").css("top","-48px"); if($("#preloading")){ $("#preloading").css("filter","none"); } $("#react-body").css("filter","none"); $("body").off("mousemove",tmp()); } $("body").on("mousemove",tmp()); },5000); }); function MainFunction(){ var UPDETE_timeout=0; function UpdateSettings(){ if(UPDETE_timeout){ clearTimeout(UPDETE_timeout); UPDETE_timeout=0; } GM_setValue("CXAndTXKTConfig", JSON.stringify(AutoSignConfig)); UPDETE_timeout=setTimeout(function(){ //=================超星主页================= AutoSignConfig.TTS_IsOpen?console.log("%c【语音播报】%c功能已%c开启","color:red","color:black","background-color:green;color:white;"):console.log("%c【语音播报】%c功能已%c关闭","color:red","color:black","background-color:red;color:white;"); if (location.href.match(/visit\/interaction/) !== null) { window.location.reload(); return; } if(location.href.match(/mobilelearn/) !== null){ cx_main(); return; } //===============腾讯课堂签到=============== if(location.href.match(/ke.qq.com/) !== null){ if(top.location==self.location){ ke(); } return; } },3000); } if(top.location==self.location){ AutoSignConfig.TTS_IsOpen?console.log("%c【语音播报】%c功能已%c开启","color:red","color:black","background-color:green;color:white;"):console.log("%c【语音播报】%c功能已%c关闭","color:red","color:black","background-color:red;color:white;"); $(document).ready(function () { GM_addStyle(` #preloading #react-body{ -webkit-transition:.7s filter; -o-transition:.7s filter; -moz-transition:.7s filter; transition:.7s filter; } .TaoMain{ color:aliceblue; } #AutoSignSettingIcon { position: fixed; left: 50%; top: -48px; margin-left: -132px; z-index: 99999999999; background-size: 100% 100%; -webkit-box-sizing: border-box; box-sizing: border-box; -webkit-transition: 0.7s; -webkit-transition-delay: 0.2s; -o-transition: 0.7s; -o-transition-delay: 0.2s; transition: 0.7s; transition-delay: 0.2s; padding: 0; cursor: pointer; width: 60px; height: 60px; border: 4px solid #00bdff96; border-radius: 50%; background: url('https://i.loli.net/2020/05/07/6xDftH98IO15MoF.png') no-repeat center center; -webkit-transform: rotate(0deg); -ms-transform: rotate(0deg); transform: rotate(0deg); } .Setting_ul { margin: 5px; } .Setting_btn { border-radius: 50%; width: 20px; height: 20px; border: none; } .Setting_On { background-color: green; } .Setting_Off { background-color: red; } .TaoMain{ z-index: 9999999999; position: fixed; top: 65px; left: 50%; } .TaoTotal { min-width:264px; opacity:0; margin-left: -132px; display:none; border-radius: 3px; border: 1px solid #A0A0A0; -webkit-box-shadow: -2px 2px 5px rgba(0,0,0,0.3); box-shadow: -2px 2px 5px rgba(0,0,0,0.3); background:rgba(0,0,0,0.8); width: -webkit-fit-content; width: -moz-fit-content; width: fit-content; padding: 15px; overflow-y:hidden ; } .TaoTotal>fieldset { margin: auto; display: -webkit-box; display: -ms-flexbox; display: flex; -webkit-box-orient: vertical; -webkit-box-direction: normal; justify-content: space-around; -ms-flex-direction: column; flex-direction: column; -ms-flex-pack: distribute; items-align: center; margin: auto; } .SettingTitle { font-size: 15px; -webkit-transition: 0.5s; -o-transition: 0.5s; transition: 0.5s; } #fieldsetAll>fieldset:hover>div { -o-transition: height 0.5s; transition: height 0.5s; -webkit-transition: height 0.5s; height: 55px; } #fieldsetAll{ max-height: 403px; overflow-y:hidden ; } #fieldsetAll>fieldset>div { -o-transition: height 0.5s; -o-transition-delay: 0.5s; transition: height 0.5s; transition-delay: 0.5s; -webkit-transition: height 0.5s; -webkit-transition-delay: 0.5s; height: 0; overflow: hidden; } .SettingTitle:hover { color: red; font-size: 18px; cursor: help; -webkit-transition: 0.7s; -webkit-transition-duration: 0.7s; -o-transition: 0.7s; -o-transition-duration: 0.7s; transition: 0.7s; transition-duration: 0.7s; } .Setting_Choice>label { margin: auto; } input.Setting_input { text-align: center; -moz-text-align-last: center; text-align-last: center; margin: 0 2px; vertical-align: middle; } input.Setting_input[type="number"] { width: 70px; color:blue; } #fieldsetAll>fieldset { margin: 5px; } hr.MyScript { margin: 0 auto; border: groove; } #react-body{ transition: .2s filter; filter:none; } `); createSettingsWindow(); }); function updateUI(){ return "
\n"+ "
\n"+ "
\n"+ "
\n"+ "涛之雨制作|前往脚本发布地址\n"+ "\n"+ "
\n"+ " 全局TTS(语音)设置\n"+ "\n"+ "
    \n"+ "
  • \n"+ "\n"+ "
  • \n"+ "
\n"+ "
\n"+ "
    \n"+ "
  • \n"+ "\n"+ "
  • \n"+ "
\n"+ "
    \n"+ "
  • \n"+ "\n"+ "
  • \n"+ "
\n"+ "
\n"+ "
\n"+ "
\n"+ "超星相关 设置\n"+ "\n"+ "
    \n"+ "
  • \n"+ "\n"+ "
  • \n"+ "
\n"+ "
\n"+ "
    \n"+ "
  • \n"+ "\n"+ "
  • \n"+ "
\n"+ "
    \n"+ "
  • \n"+ "\n"+ "
  • \n"+ "
\n"+ "
\n"+ "
\n"+ "
\n"+ ""+ /*"\n"+*/ "腾讯课堂复读机 设置\n"+ "\n"+ "
    \n"+ "
  • \n"+ "\n"+ "
  • \n"+ "
\n"+ "
\n"+ "
    \n"+ "
  • \n"+ "\n"+ "
  • \n"+ "
\n"+ "
    \n"+ "
  • \n"+ "\n"+ "
  • \n"+ "
\n"+ "
\n"+ "
\n"+ "
\n"+ " 腾讯课堂 设置\n"+ "\n"+ "
    \n"+ "
  • \n"+ "\n"+ "
  • \n"+ "
\n"+ "
\n"+ "
    \n"+ "
  • \n"+ "\n"+ "\n"+ "
  • \n"+ "
\n"+ "
    \n"+ "
  • \n"+ "\n"+ "
  • \n"+ "
\n"+ "
\n"+ "
\n"+ "
\n"+ "
\n"+ "
"; } var auto_sign_interval=0,auto_answer_interval=0; function createSettingsWindow(){ if (document.body != null && document.querySelector("#AutoSignSettingFrame") == null) { let Container = document.createElement('div'); Container.id = "AutoSignSettingFrame"; Container.innerHTML=updateUI(); document.body.appendChild(Container); var T2S_timeout=0; var icon_timeout=0; var canhiden=0,canhiden2=0; $(".TaoTotal").on('mouseover',function(e){ canhiden2=0; }); $(".TaoTotal").on('mouseout',function(e){ canhiden2=1; hidensetting(); }); $("#AutoSignSettingIcon").on('mouseover',function(e){ canhiden=0; $("#AutoSignSettingIcon").css("-webkit-transform"," rotate(180deg)").css("-ms-transform"," rotate(180deg)").css("transform"," rotate(180deg);").css("top",0); setTimeout(function() { $(".TaoTotal").css("display","block"); var fadein = setInterval(function () { $(".TaoTotal").css("opacity",Number($(".TaoTotal").css("opacity")) + 0.01); if (Number($(".TaoTotal").css("opacity")) >= 1) { clearInterval(fadein); $(".TaoTotal").css("opacity",1); } }, 10); }, 700); }); $("#AutoSignSettingIcon").on('mouseout',function(e){ canhiden=1; hidensetting(); }); function hidensetting(){ if(icon_timeout){ clearTimeout(icon_timeout); icon_timeout=0; } icon_timeout=setTimeout(function() { $(".TaoTotal").css("opacity",1); var fadeout = setInterval(function () { if(!canhiden||!canhiden2){ clearTimeout(icon_timeout); clearInterval(fadeout); icon_timeout=0; $(".TaoTotal").css("opacity",1); setTimeout(function() {hidensetting();}, 1000); return; } $(".TaoTotal").css("opacity",Number($(".TaoTotal").css("opacity")) - 0.01); if (Number($(".TaoTotal").css("opacity")) <= 0.1) { clearInterval(fadeout); $(".TaoTotal").css("opacity",0); $("#AutoSignSettingIcon").css("-webkit-transform"," rotate(0deg)").css("-ms-transform"," rotate(0deg)").css("transform"," rotate(0deg);").css("top",""); $(".TaoTotal").css("display","none"); } }, 10); }, 800); } $(".TaoTotal").on('mouseover',function(e){ if($("#preloading")){ $("#preloading").css("filter","blur(10px)"); } $("#react-body").css("filter","blur(10px)"); }); $(".TaoTotal").on('mouseout',function(e){ if($("#preloading")){ $("#preloading").css("filter","none"); } $("#react-body").css("filter","none"); }); $("#TTS_IsOpen").on('click',function(e){ var IsOpen=!!!$(e.target).attr("class").match(/Setting_On/g); $(e.target).addClass(!IsOpen?"Setting_Off":"Setting_On"); $(e.target).removeClass(!IsOpen?"Setting_On":"Setting_Off"); AutoSignConfig.TTS_IsOpen=IsOpen; UpdateSettings(); if(T2S_timeout){ clearTimeout(T2S_timeout); } T2S_timeout=setTimeout(function(){ T2STEST(); },1000); }); $("#TTS_Volce").on('input',function(e){ var Tmp=Number(e.target.value); Tmp=Tmp>15?15:Tmp<0?0:Tmp; AutoSignConfig.TTS_Volce=Tmp; $("#TTS_Volce").val(Tmp); UpdateSettings(); if(T2S_timeout){ clearTimeout(T2S_timeout); } T2S_timeout=setTimeout(function(){ T2STEST(); },1000); }); $("#TTS_Speed").on('input',function(e){ var Tmp=Number(e.target.value); Tmp=Tmp>9?9:Tmp<0?0:Tmp; AutoSignConfig.TTS_Speed=Tmp; $("#TTS_Speed").val(Tmp); UpdateSettings(); if(T2S_timeout){ clearTimeout(T2S_timeout); } T2S_timeout=setTimeout(function(){ T2STEST(); },1000); }); $("#CX_IsOpen").on('click',function(e){ var IsOpen=!!!$(e.target).attr("class").match(/Setting_On/g); $(e.target).addClass(!IsOpen?"Setting_Off":"Setting_On"); $(e.target).removeClass(!IsOpen?"Setting_On":"Setting_Off"); AutoSignConfig.CX_IsOpen=IsOpen; UpdateSettings(); }); $("#CX_WaitingTime").on('input',function(e){ AutoSignConfig.CX_WaitingTime=Number(e.target.value); UpdateSettings(); }); $("#CX_MaxWaitingCount").on('input',function(e){ AutoSignConfig.CX_MaxWaitingCount=Number(e.target.value); UpdateSettings(); }); $("#TXKT_Signing_WaitingTime").on('input',function(e){ AutoSignConfig.TXKT_Signing_WaitingTime=Number(e.target.value); UpdateSettings() }); $("#TXKT_Ansering_IsRandom").on('click',function(e){ var IsOpen=!!!$(e.target).attr("class").match(/Setting_On/g); $(e.target).addClass(!IsOpen?"Setting_Off":"Setting_On"); $(e.target).removeClass(!IsOpen?"Setting_On":"Setting_Off"); AutoSignConfig.TXKT_Ansering_IsRandom=IsOpen; UpdateSettings() }); $("#TXKT_Ansering_IsOpen").on('click',function(e){ var IsOpen=!!!$(e.target).attr("class").match(/Setting_On/g); $(e.target).addClass(!IsOpen?"Setting_Off":"Setting_On"); $(e.target).removeClass(!IsOpen?"Setting_On":"Setting_Off"); AutoSignConfig.TXKT_Ansering_IsOpen=IsOpen; UpdateSettings() }); $("#TXKT_Ansering_WaitingTime").on('input',function(e){ AutoSignConfig.TXKT_Ansering_WaitingTime=Number(e.target.value); UpdateSettings(); }); $("#TXKT_Repeater_IsOpen").on('click',function(e){ var IsOpen=!!!$(e.target).attr("class").match(/Setting_On/g); if(IsOpen){ var boo = confirm('这是一个测试的选项,请谨慎打开开关,\n如果异常请打开console,并把报错的内容反馈到插件的主页(右上角有链接)\n你确定要打开么?') //confirm 会返回你选择的选项,然后可以依据选择执行逻辑 if(!boo){ return; } } $(e.target).addClass(!IsOpen?"Setting_Off":"Setting_On"); $(e.target).removeClass(!IsOpen?"Setting_On":"Setting_Off"); AutoSignConfig.TXKT_Repeater_IsOpen=IsOpen; UpdateSettings() }); $("#TXKT_Repeater_WaitingTime").on('input',function(e){ AutoSignConfig.TXKT_Repeater_WaitingTime=Number(e.target.value); UpdateSettings(); }); $("#TXKT_Repeater_MaxWaitingCount").on('input',function(e){ AutoSignConfig.TXKT_Repeater_MaxWaitingCount=Number(e.target.value); UpdateSettings(); }); $("#AutoSignSettingIcon").on('dblclick',function(e){ if(window.confirm('你确定要删除已有设置吗?')){ //alert("确定"); AutoSignConfig = DefaultConfig; UpdateSettings(); alert("清除成功!即刻生效"); createSettingsWindow(); return true; }else{ //alert("取消"); return false; } }); }else{ document.getElementById("AutoSignSettingFrame").innerHTML=updateUI(); } } } function b64en(str) { return btoa(encodeURIComponent(str)); } function b64de(str) { return decodeURIComponent(atob(str)); } window.T2STEST=function (){ T2S("这里是语音测试,如果声音大小,或是语速不合适请修改参数。Power By 涛之雨"); } //=================超星主页================= if (location.href.match(/visit\/interaction/) !== null) { window.onload = function () { cx_sign(); } return; } if(location.href.match(/mobilelearn/) !== null){ $(document).ready(function () { cx_main(); }); return; } if(location.href.match(/ke.qq.com/) !== null){ if(top.location==self.location){ $(document).ready(function () { ke(); }); } return; } var auto_Repeater_timeout=0; var sign_times=0; var answer_times=0; var repeat_times=0; var blacklist = ""; function ke(){ if(auto_Repeater_timeout){ clearTimeout(auto_Repeater_timeout); auto_Repeater_timeout=0; } function auto_sign(timeout=5000){ if(auto_sign_interval){ clearInterval(auto_sign_interval); } auto_sign_interval = setInterval(function () { try{ if($(".tip")[0].innerText.match(/签到/)){ if($(".btn-group")[0]!==undefined){ if(auto_sign_interval){ clearInterval(auto_sign_interval); } $(".btn-group")[0].children[0].click(); setTimeout(function () { $(".btn-group")[0].children[0].click(); sign_times++; T2S("自动签到插件,签到成功!本节课累积已为您签到,"+sign_times+"次。"); auto_sign(Number(AutoSignConfig.TXKT_Signing_WaitingTime)); console.log("%c【腾讯课堂自动签到插件】%c\n于 %s %c签到成功!\n本节课累积已为您签到%c"+sign_times+"次%c!","color:white;background-color:blue;font-size:20px","color:red;font-size:20px",(new Date().toLocaleTimeString()),"color:black","color:red;font-size:20px","color:black"); },500); } } }catch(e){} }, timeout); } function auto_Answer(timeout=1000){ var isAnswering=false; var isfristtime=true; var tx_timeout,timeout_min,timeout_sec,timeout_all,tmp_timeout=0,checkout_times=0; var isbackingtime=AutoSignConfig.TXKT_Ansering_WaitingTime<0?true:false; if(AutoSignConfig.TXKT_Ansering_WaitingTime===0){ return; } var timeout_def=Math.abs(AutoSignConfig.TXKT_Ansering_WaitingTime); var getrandomchoice=function(totalnumber=2){ return Math.floor((Math.random()*totalnumber)+1)-1; } var answering=function(israndom=true){ console.log("开始答题") var anser_type=$(".head-text")[0].innerHTML; var mychoice=AutoSignConfig.TXKT_Ansering_IsRandom?getrandomchoice($(".s-f-rc-item").length):0; console.info("anser_type:"+anser_type); $(".s-f-rc-item")[mychoice].click()//选择 document.querySelector("#react-body > div.examcard-dialog > div.im-dialog-wrap > div > div.btn-group > span").click()//提交 setTimeout(function(){ document.querySelector("#react-body > div.examcard-dialog > div.im-dialog-wrap > div > div.dialog-head.drag-handler > i").click()//关闭窗口 answer_times++; T2S("辅助答题插件,答题成功!本次选择为:"+["A","B","C","D","E"][mychoice]+"。本节课累积已为您辅助,"+answer_times+"次。"); console.log("%c【腾讯课堂自动签到插件】%c\n%s %c辅助答题成功!\n本次选择为:"+["A","B","C","D","E"][mychoice]+"。\n本节课累积已为您答题%c"+answer_times+"次%c!","color:white;background-color:blue;font-size:20px","color:red;font-size:20px",(new Date().toLocaleTimeString()),"color:black","color:red;font-size:20px","color:black"); isAnswering=false; },200); } if(auto_answer_interval){ clearInterval(auto_answer_interval); } auto_answer_interval = setInterval(function () { try{ if($(".head-text").length){//单选题、多选题、(未知) if($(".head-text")[0].innerHTML.match(/选题/)){ if(isfristtime){ isfristtime=false; T2S("检测到答题窗口,正在密切监视中。。。"); } tx_timeout=$(".xq_num")[0].innerHTML; timeout_min=Number(tx_timeout.match(/\d{2}/g)[0]); timeout_sec=Number(tx_timeout.match(/\d{2}/g)[1]); timeout_all=timeout_min*60+timeout_sec-1;//当前答题的剩余时间 console.log("答题辅助:==%s==\n"+timeout_all,(new Date().toLocaleTimeString())); if(!isAnswering){ if($(".drag-handler").length!="0"){//存在答题窗口 if(isbackingtime){ checkout_times=timeout_all checkout_times<=timeout_def?( console.log("时间到!开始执行辅助作答\n随机选择:%c%s",(AutoSignConfig.TXKT_Ansering_IsRandom?"color:green":"color:red"),(AutoSignConfig.TXKT_Ansering_IsRandom?"开":"关")), answering(AutoSignConfig.TXKT_Ansering_IsRandom), isAnswering=true ):( console.log("监视中,剩余等待时间:%c%s%c秒","color:red",(timeout_all-timeout_def),"color:black") ); }else{ checkout_times>=timeout_def?( console.log("时间到!开始执行辅助作答\n随机选择:%c%s",(AutoSignConfig.TXKT_Ansering_IsRandom?"color:green":"color:red"),(AutoSignConfig.TXKT_Ansering_IsRandom?"开":"关")), answering(AutoSignConfig.TXKT_Ansering_IsRandom), isAnswering=true ):( checkout_times++, console.log("监视中,剩余等待时间:%c%s%c秒","color:red",(timeout_def-checkout_times),"color:black") ); } } } } }else{ checkout_times=0;//没有签到窗口 isfristtime=true; } }catch(e){ checkout_times=0;//未知错误吧。。。。 isfristtime=true; console.error("未知错误!\n请复制错误信息提交反馈====>>\n\n",e); } }, timeout); } function auto_Repeater(waitetime = 1000, maxtimes = 7) { var arr = document.querySelectorAll(".js-chat-item-msg-content span"); var i = 0; var arrlength=arr.length - 1 ; if(arrlength>=maxtimes){ try{ while (arr[arrlength- i].innerHTML.trim() == arr[arrlength- 1-i].innerHTML.toString().trim()) { if (arr[arrlength- i].innerHTML.toString().trim() == blacklist) { i = -2; break; } i++; } if (i +1>= maxtimes) { console.log("有效重复:" + (i+1) + "次\n有效词:“"+arr[arrlength- i].innerHTML.toString().trim()+"”"); if(!document.querySelector('div.ql-editor.ql-blank')){ document.querySelector('.ql-editor').innerHTML=""; } var a=setInterval(function() { try{ document.querySelector('div.ql-editor.ql-blank').firstElementChild.innerHTML = arr[arrlength- 1].innerHTML.toString().trim(); clearInterval(a); setTimeout(function() { document.querySelector('button.im-btn.text-editor-btn.btn-default.btn-s').click(); repeat_times++; console.log("%c【腾讯课堂·复读机】%c\n于 %s %c复读成功!\n本节课累积已为您签到%c"+repeat_times+"次%c!\n本次复读内容:%c"+arr[arrlength- 1].innerHTML.toString().trim(),"color:white;background-color:blue;font-size:20px","color:red;font-size:20px",(new Date().toLocaleTimeString()),"color:black","color:red;font-size:20px","color:black","color:red;font-size:20px"); }, 1000); }catch(e){} },1); blacklist = arr[arr.length - 1].innerHTML.toString().trim(); i = -1; } }catch(e){ console.error("未知错误!\n请复制错误信息提交反馈====>>\n\n",e); } }else{ i=-1; } console.log("复读机检测,检测状态:正常,\n"+(i==-1?"评论不足"+maxtimes+"条,当前条数:"+arrlength:i==-2?"黑名单词组“"+arr[arrlength- 1].innerHTML.toString().trim()+"”":"重复条数:"+(i+1))); if (i == -1||i==-2) { auto_Repeater_timeout=setTimeout(function() { auto_Repeater(Number(AutoSignConfig.TXKT_Repeater_WaitingTime),Number(AutoSignConfig.TXKT_Repeater_MaxWaitingCount)); }, 10000); } else { auto_Repeater_timeout=setTimeout(function() { auto_Repeater(Number(AutoSignConfig.TXKT_Repeater_WaitingTime),Number(AutoSignConfig.TXKT_Repeater_MaxWaitingCount)); }, waitetime); } } console.group("[%c腾讯课堂插件%c开启情况]","color:red;","color:black;"); AutoSignConfig.TXKT_Signing_WaitingTime?( console.log("%c【腾讯课堂·自动签到】%c功能已%c开启","color:red","color:black","background-color:green;color:white;"), setTimeout(function() {auto_sign(Number(AutoSignConfig.TXKT_Signing_WaitingTime));},1) ):console.log("%c【腾讯课堂·自动签到】%c功能已%c关闭","color:red","color:black","background-color:red;color:white;"); AutoSignConfig.TXKT_Ansering_IsOpen?( console.log("%c【腾讯课堂·辅助作答】%c功能已%c开启","color:red","color:black","background-color:green;color:white;"), setTimeout(function() {auto_Answer();},1) ):console.log("%c【腾讯课堂·辅助作答】%c功能已%c关闭","color:red","color:black","background-color:red;color:white;"); AutoSignConfig.TXKT_Repeater_IsOpen?( console.log("%c【腾讯课堂·自动复读】%c功能已%c开启","color:red","color:black","background-color:green;color:white;"), setTimeout(function() {auto_Repeater(Number(AutoSignConfig.TXKT_Repeater_WaitingTime),Number(AutoSignConfig.TXKT_Repeater_MaxWaitingCount));},1) ):console.log("%c【腾讯课堂·自动复读】%c功能已%c关闭","color:red","color:black","background-color:red;color:white;"); console.groupEnd("[腾讯课堂插件开启情况]"); } function cx_sign(){ if(!AutoSignConfig.CX_IsOpen){//关闭主页自动签到 return; } AutoSignConfig.CX_IsOpen?console.log("%c【超星·主页签到】%c功能已%c开启","color:red","color:black","background-color:green;color:white;"):console.log("%c【超星·主页签到】%c功能已%c关闭","color:red","color:black","background-color:red;color:white;"); var wait4time=Number(AutoSignConfig.CX_WaitingTime); var wait_format=(parseInt(wait4time/60)?(parseInt(wait4time/60)+"分钟"):"")+ (parseInt(wait4time%60)?parseInt(wait4time%60)+"秒":""); console.group("$$课程信息$$(点我收起/展开)"); console.log("一共有%c"+$(".ulDiv .clearfix").length+"%c门课程:","color:blue","color:black"); T2S("签到插件开启,一共有"+$(".ulDiv .clearfix").length+"门课程。监视时长,"+wait_format+"。"); $(".ulDiv .clearfix").each(function(){ var that=this; var coursename=$(that)[0].children[0].innerHTML; var courseID=$(that)[0].children[0].href.match(/courseId=\d+/g)[0].match(/\d+/g)[0]; console.log("专业:%c%s\n%ccourseID:%c"+courseID+"\n%cclassID为:%c"+$(that)[0].children[0].href.match(/clazzid=\d+/g)[0].match(/\d+/g)[0],"color:red",coursename,"color:black","color:red","color:black","color:red"); var sign_url="https://mobilelearn.chaoxing.com/widget/pcpick/stu/index?courseId="+$(that)[0].children[0].href.match(/courseId=\d+/g)[0].match(/\d+/g)[0]+"&coursename="+b64en(coursename)+"&jclassId="+$(that)[0].children[0].href.match(/clazzid=\d+/g)[0].match(/\d+/g)[0]; var tmp = document.createElement("iframe"); tmp.id = 'loginframe_'+$(that)[0].children[0].href.match(/courseId=\d+/g)[0].match(/\d+/g)[0]; tmp.src = sign_url; tmp.style = "display:none;width: 0px;height: 0px;position: fixed;left: 0px;bottom: 0px;z-index: -99;"; $("body")[0].append(tmp); }); console.groupEnd("$$课程信息$$(点我收起/展开)"); } function cx_main(){ if(!AutoSignConfig.CX_IsOpen){//关闭主页自动签到 return; } var wait4time=Number(AutoSignConfig.CX_WaitingTime); var wait_format=(parseInt(wait4time/60)?(parseInt(wait4time/60)+"分钟"):"")+ (parseInt(wait4time%60)?parseInt(wait4time%60)+"秒":""); wait4time*=1000; var url_sign=location.href.match(/tao_auto_refresh_time=\d+/g); var coursename=""; try{ coursename=location.href.match(/coursename=[A-Za-z0-9/\+=]+/g)[0].substring(11); }catch(e){} var waitingTimes=Number((url_sign===null)?0:url_sign[0].match(/\d+/g)[0]),MAX_waittingTimes=Number(AutoSignConfig.CX_MaxWaitingCount); waitingTimes++; try{ if($(".qdhover").length!==0){ var getmsg=$(".qdhover").parent().parent().parent()[0].getAttributeNode("onclick").nodeValue.match(/\d+/g); if(getmsg[1]==2){//普通签到 var activeId=getmsg[0]; var courseId = $("#courseId").val(); var classId = $("#classId").val(); var fid = $("#fid").val(); var url="/widget/sign/pcStuSignController/signIn?activeId="+activeId+"&classId="+classId+"&coursename="+coursename+"&fid="+fid+"&courseId="+courseId; var tmp = document.createElement("iframe"); tmp.id = 'loginframe'; tmp.src = url; tmp.style = "display:none;width: 0px;height: 0px;position: fixed;left: 0px;bottom: 0px;z-index: -99;"; $("body")[0].append(tmp); $("#loginframe").load(function () { if(window.frames[0].$("title")[0].text.match("成功")!==""){ if(top.location==self.location){ T2S("当前课程,签到成功"), console.log("%c【当前课程】签到成功!","color:white;font-size:30px;background-color:green"); $(".qdhover").parent().parent().parent().children().children()[1].innerHTML+=" 签到成功!"; $(this).remove(); }else{ T2S(b64de(coursename)+",签到成功"); console.log("%c【%s】签到成功!","color:white;font-size:30px;background-color:green",b64de(coursename)); } }else{ T2S("未知错误!请手动签到!"); alert("未知错误!请手动签到!"); } }); }else{//不支持 T2S(top.location==self.location?"当前课程":b64de(coursename)+",出现非支持签到模式!请手动签到!!!"); alert("【"+top.location==self.location?"当前课程":b64de(coursename)+"】出现非支持签到模式!请手动签到!!!"); } }else{ if(MAX_waittingTimes&&waitingTimes>=MAX_waittingTimes){ T2S(top.location==self.location?"当前课程":b64de(coursename)+"已达尝试上限"+MAX_waittingTimes+"次,已停止"); console.log("%c【%s】%c已达尝试上限%s次,已停止","color:red",top.location==self.location?"当前课程":b64de(coursename),"color:black",MAX_waittingTimes); return; }else{ console.log("%c【%s】%c第"+waitingTimes+"次尝试,\n暂无签到任务,%s后自动再次尝试","color:red",top.location==self.location?"当前课程":b64de(coursename),"color:black",wait_format); setTimeout(function () { window.location.href=location.href.indexOf("tao_auto_refresh_time") > -1 ? (location.href.replace(new RegExp("tao_auto_refresh_time=\\d+",'g'),"tao_auto_refresh_time="+waitingTimes)) :( location.href + (location.href.indexOf("?") > -1 ? "&" : "?") + "tao_auto_refresh_time=" + waitingTimes); },wait4time); } } }catch(e){ console.log(e); } } } })();