腾讯课堂、超星自动签到(临时解决方案)

腾讯课堂、超星自动签到

目前為 2020-04-23 提交的版本,檢視 最新版本

// ==UserScript==
// @name	腾讯课堂、超星自动签到(临时解决方案)
// @description	腾讯课堂、超星自动签到
// @namespace CX&TXKT_auto_sign
// @author	涛之雨
// @version	0.1.0
// @grant	none
// @run-at	document-start
// @require	https://libs.baidu.com/jquery/2.1.4/jquery.min.js
// @match	*://ke.qq.com/webcourse/index.html*
// @match	*://mobilelearn.chaoxing.com/widget/pcpick/stu/index*
// @match	*://*.chaoxing.com/visit/interaction*
// @license	GPL-3.0-only
// @icon	https://i.loli.net/2020/03/04/D3h1iWSFeyc8AKG.png
// @home-url	https://gf.qytechs.cn/zh-CN/scripts/401115
// ==/UserScript==


/*
 * 更新:
 * 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://gf.qytechs.cn/zh-CN/scripts/401115
//吾爱说明:https://www.52pojie.cn/thread-1163575-1-1.html
//CSDN说明:

//未做混淆或加密,
//按F12打开console即可看到日志
//懂js可以自行DIY

try{
	/*=================================================配置开始====================================================*/
	//这里是配置!
	//如果不懂如何更改请不要自行改动,以免出错

	/*==========超星相关配置================*/
	var 超星主页自动签到=true;
	//可填true/false
	//当值为true的时候,将会在您打开主页
	//(形如http://i.mooc.chaoxing.com/)
	//的时候自动对所有的课程进行签到检测
	//否则不会。
	//如果您的电脑性能较差,请慎重考虑是否需要打开


	var 超星签到等待时间=30000;
	//上面的数字部分是超星每次检测后等待的时长,单位为毫秒
	//上述时间为30秒
	//注:切勿设置过短,否则打开主页是有几率因同时操作数过大而卡死!!!
	//推荐设置为十几秒到一分钟()


	var 超星签到最大检测次数=20;
	//上面的数字部分是超星检测的最大等待次数,
	//建议设置等待时间*等待时长为十几分钟,以防浏览器崩溃
	//上述设置为最大20次,即检测10分钟。
	//设置为0则不限制
	/*==========超星相关配置================*/


	/*========腾讯课堂相关配置==============*/
	var 腾讯课堂签到等待时长=5000;
	//解释同上,不过此处推荐设置的稍微短一些比如几秒钟。
	//因为课堂上的签到时间较短,而且当前仅有一处,
	//不会出现好几个签到任务,不会影响使用
	//上述设置为每5秒钟检测一次
	//值为0表示关闭该功能


	var 辅助作答开关=false;
	//警告!本开关仅供临时离身救急使用!!
	//可填true/false
	//默认关闭,选择true后会根据您的配置,作出相应的选项
	//(如在最后5秒的时候如果没有选择答案将自动选择)
	//可配合下面的【随机选则】【辅助作答时机】使用
	//请注意!当您选择true的时候,即视为您已经知晓风险!恕不另行告知!


	var 随机选择=true;
	//仅当【辅助作答开关】为true的时候生效。
	//顾名思义,打开后会在选项中随机选择任意一个作为答案提交。
	//如果关闭,将每次都选择第一个(A)选项


	var 辅助作答时机=-20;
	//仅当【辅助作答开关】为true的时候生效。
	//辅助作答的时机,单位:秒
	//例如检测到作答窗口后20秒钟(非上述例子)后如果您没有自行提交答案,将会自动选择选项,
	//当数值为负数的时候表示还剩5秒的时候如果没有提交,将会自动选择选项。(推荐)
	//数值为0表示检测到答题窗口立即作答(不推荐)
	//注:选择的选项和【随机选择的开关有关】

	/*========腾讯课堂相关配置==============*/



	/*=================================================配置结束====================================================*/
}catch(e){
	alert("您的设置存在问题!\n将会按照原来内置的设置运行");
	var iserror=1;
}

(function() {
	'use strict';
	function b64en(str) {
		return btoa(encodeURIComponent(str));
	}

	function b64de(str) {
		return decodeURIComponent(atob(str));
	}
	//=================超星主页=================
	if (location.href.match(/visit\/interaction/) !== null) {
		超星主页自动签到?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(!超星主页自动签到){//关闭主页自动签到
			return;
		}
		window.onload = function () {
			console.group("$$课程信息$$(点我收起/展开)");
			console.log("一共有%c"+$(".ulDiv .clearfix").length+"%c门课:","color:blue","color:black");
			$(".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);
// 				$("#loginframe_"+$(that)[0].children[0].href.match(/courseId=\d+/g)[0].match(/\d+/g)[0]).load(function () {
// 				});
			});
			console.groupEnd("$$课程信息$$(点我收起/展开)");
		}
		return;
	}

	if(location.href.match(/mobilelearn/) !== null){
		var waite4time=iserror==1?30000:Number(超星签到等待时间)<100?100:Number(超星签到等待时间);
		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){coursename="未知课程(可能是链接错误)"}
		var waitingTimes=Number((url_sign===null)?0:url_sign[0].match(/\d+/g)[0]),MAX_waittingTimes=Number(超星签到最大检测次数);
		$(document).ready(function () {
			try{
				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 () {
						window.frames[0].$("title")[0].text.match("成功")!==""?
							(top.location==self.location?(
							console.log("%c【当前课程】签到成功!","color:white;font-size:30px;background-color:green"),
							$(this).remove()):(
							console.log("%c【%s】签到成功!","color:white;font-size:30px;background-color:green",b64de(coursename))
						)
							):alert("未知错误!请手动签到!");
					});
				}else{//不支持
					alert("【"+b64de(coursename)+"】出现非支持签到模式!请手动签到!!!");
				}
			}catch(e){
				if(MAX_waittingTimes&&++waitingTimes>=MAX_waittingTimes){
					console.log("课程%c【%s】%c已达尝试上限%s,已停止","color:red",b64de(coursename),"color:black",MAX_waittingTimes);
					return;
				}else{
					console.log("课程%c【%s】%c第"+waitingTimes+"次尝试,\n暂无签到任务,%sms后自动再次尝试","color:red",b64de(coursename),"color:black",waite4time?waite4time:60000);
					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);
					},waite4time?waite4time:60000);
				}
			}
		});
		return;
	}


	//===============腾讯课堂签到===============
	if(location.href.match(/ke.qq.com/) !== null){
		if(top.location==self.location){
			$(document).ready(function () {
				function auto_sign(timeout=5000){
					var sign_times=0;
					var timeouting = setInterval(function () {
						try{
							if($(".tip")[0].innerText.match(/签到/)){
								var tx_timeout=$(".xq_num")[0].innerHTML;//00:05
								var timeout_min=Number(tx_timeout.match(/\d{2}/g)[0]);
								var timeout_sec=Number(tx_timeout.match(/\d{2}/g)[1]);
								var timeout_all=timeout_min*60+timeout_sec-1;//提前一秒,防止误差
								console.log("签到:==%s==\n"+timeout_all,(new Date().toLocaleTimeString()));
							}
						}catch(e){}
					}, 1000);
					var auto_sign_interval = setInterval(function () {
						try{
							if($(".tip")[0].innerText.match(/签到/)){
								if($(".btn-group")[0]!==undefined){
									$(".btn-group")[0].children[0].click();
									setTimeout(function () {
										$(".btn-group")[0].children[0].click();
										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");
									},1000);
								}
							}
						}catch(e){}
					}, timeout);
				}

				function auto_Answer(timeout=1000){
					var sign_times=0;
					var tx_timeout,timeout_min,timeout_sec,timeout_all,checkout_times=0;
					var isbackingtime=辅助作答时机<0?true:false;
					var timeout_def=Math.abs(辅助作答时机)
					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;
						console.info("anser_type:"+anser_type);
						$(".s-f-rc-item")[随机选择?getrandomchoice($(".s-f-rc-item").length):0].click()
						//关闭按钮没找到,上面的点击未进行测试!QAQ
						//尝鲜请慎重
						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");

					}
					console.group("$$辅助作答模块$$(点我收起/展开)");
					var auto_sign_interval = setInterval(function () {

						try{

							if($(".head-text").length){//单选题、多选题、(未知)
								if($(".head-text")[0].match(/选题/)){
									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($(".drag-handler").length!="0"){//存在答题窗口
										checkout_times>=timeout_def?(console.log("时间到!开始执行辅助作答\n随机选择:%c%s","color:red",随机选择?"开":"关"),console.groupEnd("$$辅助作答模块$$(点我收起/展开)"),answering(随机选择)):(isbackingtime?"":checkout_times++,console.log("监视中,剩余等待时间:%c%s%c秒","color:red",(timeout_all-timeout_def),"color:black"));
									}
								}
							}else{
								checkout_times=0;//没有签到窗口
							}
						}catch(e){
							checkout_times=0;//没有签到窗口
						}
					}, timeout);
				}
				腾讯课堂签到等待时长?(console.log("%c【腾讯课堂自动签到】%c功能已%c开启","color:red","color:black","background-color:green;color:white;"),auto_sign(iserror?"":Number(腾讯课堂签到等待时长))):console.log("%c【腾讯课堂自动签到】%c功能已%c关闭","color:red","color:black","background-color:red;color:white;");

				辅助作答开关?(console.log("%c【腾讯课堂辅助作答】%c功能已%c开启","color:red","color:black","background-color:green;color:white;"),console.warn("%c辅助作答为测试功能!!!请勿信任该功能!!!!\n\n%c如果出现未知错误请立即\n把%c【辅助作答开关】%c改成%cfalse%c并%c立即刷新%c!","background-color:red;color:white;","background-color;color;","background-color:red;color:white;font-size:30px","background-color;color;font-size;","color:red;font-size:30px","color;font-size","color:blue;font-size:30px","background-color;color;font-size"),auto_Answer()):console.log("%c【腾讯课堂辅助作答】%c功能已%c关闭","color:red","color:black","background-color:red;color:white;");
			});
		}
		return;
	}
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址