// ==UserScript== // @name 小小星继续教育学习工具 V2.0 // @namespace SmilerGo // @version 2.0 // @description 成都市中小学继续教育网学习小工具 // @author 小新学IT // @match https://www.cdjxjy.com/IndexMain.aspx // @icon https://t7.baidu.com/it/u=1951548898,3927145&fm=193&f=GIF // @grant none // @license MIT // @downloadURL none // ==/UserScript== (function() { var current = 0; var alreadV = false; var globalControl = false; window.listInit = function () { console.log("列表数据初始化"); if (sessionStorage.notFirst === undefined) { sessionStorage.notFirst = 1; } // var w = window.fnode4; var w = $("#fnode4"); // 课程名称(可点击) let aList = $("#UpdatePanel1 .table_all .litable .color_span",window.frames["fnode4"].document); console.log("课程信息"); console.log(aList); // 课程名称(可点击) var btnList = $("#UpdatePanel1 .table_all .litable .xx_ben a", window.frames["fnode4"].document); // 课程信息检索 console.log("课程名称点击按钮"); console.log(btnList); // list 数据 var litable = $("#UpdatePanel1 .table_all .litable", window.frames["fnode4"].document); // 翻页按钮 var actionList = $("#AspNetPager1 div", window.frames["fnode4"].document).eq(0).children().get(); var index = 0; if (actionList.length >= 0) { var selectclassid = getParams('scid', btnList[index].href); console.log("当前课程ID:" + selectclassid); var pyh_doc_ht = "当前学习课程ID:" + selectclassid; $("#pyh_dis").html(pyh_doc_ht); // 锁定新的课程 lockCourse(selectclassid); } else { current += 1 if (current < actionList.length) { console.log(actionList[current]); actionList[current].click(); window.setTimeout(listInit, 3000); } else { console.log('没有找到需要学习的课程'); } } // 课程锁定 function lockCourse(id) { $.ajax({ url: "/ashx/SelectApi.ashx?a=UpdateSelectState", type: "POST", data: { "selectclassid": id }, dataType: "json", success: function (data) { console.log("课程锁定结果:" + data); current = 0; alreadV = false; aList[index].click(); window.setTimeout(studyCourse, 3000); }, complete: function(){ current = 0; alreadV = false; aList[index].click(); window.setTimeout(studyCourse, 3000); window.setTimeout(printStatus, 1000); console.log("课程锁定完成!"); } }); } // 学习课程 function studyCourse () { var w = document.fnode4; w.updata = updata; w.showyzm = showyzm; // openOtherInfo() var timer = window.setInterval(function () { w.UpdateTime(); $.ajax({ url: "/ashx/SelectApi.ashx?a=UpdateLookTime", type: "POST", data: { "selectclassid": w.selectclassid }, dataType: "json", success: function (data) { if (w.Startime > 2700 || (data.message.indexOf('已完成') > -1) || !data) { console.log("当前课程已学习结束!") alreadV = true; window.clearInterval(timer); window.location.reload(); window.setTimeout(listInit, 3000); } }, complete: function(){ console.log("5分钟刷新时间记录已执行!"); } }); }, 300000); window.setTimeout(automaticRecording, 60000); } function showyzm () { console.log("验证码弹窗已调用"); } function updata() { var w = document.fnode4; console.log(w); w.UpdateTime(); $.ajax({ url: "/ashx/SelectApi.ashx?a=UpdateLookTime", type: "POST", data: { "selectclassid": w.selectclassid }, dataType: "json", success: function (data) { console.log("课程锁定时间更新结果:"); console.log(data); } }); } // 自动填写学习记录 function automaticRecording () { var w = document.fnode4; w.alert = function () {} // 点击获取评论 var btn = $("#btncommment", w.document).get()[0]; // 学习记录 var tab = $(".course-tab .tabItem", w.document).eq(1).get()[0]; btn.click(); tab.click(); window.setTimeout(function () { console.log("自动填写观看评语中..."); var firstlabel = $("#UpdatePanel2 .label", w.document).eq(0).get()[0]; var content = firstlabel.innerHTML || ''; console.log(firstlabel); console.log(content); $("#txtareainnertContents", w.document).val(content); $("#txtareaExperience", w.document).val(content); $("#btnaddRecord", w.document).click(); }, 3000) } } // 获取当前窗口相对路径 function GetUrlRelativePath(){ let pathName = window.location.pathname; console.log("当前窗口路径:" + pathName); return pathName; } console.log("当前窗口路径:" + GetUrlRelativePath() + window.location.hash); if (GetUrlRelativePath() === "/IndexMain.aspx") { // window.location.href='https://www.cdjxjy.com/IndexMain.aspx#/student/SelectCourseRecord.aspx'; // window.location.replace("https://www.cdjxjy.com/IndexMain.aspx#/student/SelectCourseRecord.aspx") console.log("进入/IndexMain.aspx"); globalControl = false; } if (GetUrlRelativePath() === '/IndexMain.aspx' && location.hash.indexOf('SelectCourseRecord') > -1) { // globalControl = window.confirm('是否开启自动化操作???'); // window.location.reload(); console.log("进入SelectCourseRecord"); layer.msg('窗口核验完毕!!!'); globalControl = true } var progressParent = "
" +"starrt"+ +"
"; console.log("进度条代码" + progressParent); $("#form1").prepend(progressParent); // window.setTimeout(listInit, 3010); // 观看五十分钟 + 10s window.setTimeout(listInit, 1000); // 开始执行课程数据解析 function printStatus() { var w = document.fnode4; var html_time = "<->><<-> 你已经学习了" + w.hou + "小时" + w.min + "分"+ w.sec + "秒"; $("#pyh_dis").html(html_time); if(!alreadV) { window.setTimeout(printStatus, 1000); } } // 获取课程信息 function getParams(name, target) { var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象 var r = target.substr(1).match(reg); //匹配目标参数 if (r != null) return unescape(r[2]); return null; //返回参数值 } })();