您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
广东省国家工作人员学法考试系统辅助学习
当前为
// ==UserScript== // @name 广东省国家工作人员学法考试系统辅助-自动考试 // @namespace https://gf.qytechs.cn/ // @version 1.7 // @description 广东省国家工作人员学法考试系统辅助学习 // @author DuoMx // @match http*://xfks-study.gdsf.gov.cn/study/* // @icon http://xfks-study.gdsf.gov.cn/study/static/images/favicon.ico?v2019031285 // @license GPLv3 // @require https://code.jquery.com/jquery-2.2.4.min.js // @grant GM_setValue // @grant GM_getValue // @grant GM_notification // ==/UserScript== this.$ = this.jQuery=jQuery.noConflict(true); (function() { 'use strict'; // Your code here... var fullurl = window.location.href; $("[name='password']").val("xfks1234"); var totalAnswer={}; var courseList =[];//课程列表 var chapterList =[];//章节列表 var exerciseList=[];//练习列表 var courseCount = 0; var chapterCount = 0; var exerciseCount=0; var delaytime = 10000; //统计页面开始收集课程资料 if(fullurl.indexOf("study/statistics")>0){ var isstart=confirm("是否开始学习!"); if (isstart==true){ var isquick = confirm("是否选择极速学习!"); if (isquick==true){ delaytime =10; GM_setValue("delaytime", delaytime); } else{ delaytime =100; GM_setValue("delaytime", delaytime); } FindCourseList(); StartLearnAll(); StartExercise(); } else{ alert("你已取消学习,如需学习,请刷新页面!"); } } //检测课程 function FindCourseList(){ var indexdom; $.ajax({ type : "get", url : "http://xfks-study.gdsf.gov.cn/study/index", data : null, async : false, success : function(data){ indexdom = $(data).find("#pre"); } }); updateNotice("开始检测课程","脚本启动成功"); console.log("开始检测课程"); indexdom.find(".card.current").each(function (){ courseList.push($(this).children("h3").children("a").attr("href")); courseCount++; }); console.log("检测到"+courseCount+"个课程"); console.log("开始检测章节及练习题"); for(let i=0;i<courseList.length;i++){ var percentnum = ((i+1) / courseList.length*100).toFixed(0); //console.log(noticeText); FindChapterList(courseList[i]); } updateNotice("检测到"+chapterCount+"个章节,"+exerciseCount+"份练习题。\n正在学习,请耐心等待。","开始学习!"); console.log("检测到"+chapterCount+"个章节,"+exerciseCount+"份练习题。"); GM_setValue("chapterList", chapterList); GM_setValue("exerciseList", exerciseList); } //检测章节 function FindChapterList(courseUrl){ var chaptersdom; var rootdom; $.ajax({ type : "get", url : courseUrl, data : null, async : false, success : function(data){ rootdom = $(data); chaptersdom = $(data).find("#chapter-none"); } }); chaptersdom.children("li").each(function(){ if($(this).find("a").attr("href").indexOf("study/course")>0){ chapterList.push("http://xfks-study.gdsf.gov.cn"+$(this).find("a").attr("href")); chapterCount++; } }) rootdom.find("td.title").find("a[onclick]").each(function (){ var onclickString = $(this).attr("onclick"); var courseIdString = onclickString.split(',')[0].split('(')[1]; var chapterIdString=onclickString.split(',')[1].split(')')[0]; exerciseList.push({'courseId':courseIdString,'chapterId':chapterIdString}); exerciseCount++; }); } //开始全部学习 function StartLearnAll () { var chapterList = GM_getValue("chapterList", null); for(let i=0;i<chapterList.length;i++){ var percentnum = ((i+1) / chapterList.length*100).toFixed(0); //sleep(delaytime); var getchaptersuccess = getChapterContent(chapterList[i]); if(getchaptersuccess){ var indexchapter = chapterList[i].indexOf("chapter"); var chapternum = chapterList[i].substring(indexchapter+8); //updateNotice('获取章节资料:'+chapternum+'成功,进度:'+percentnum+"%。") console.log('获取章节:'+chapternum+'成功,进度:'+percentnum+"%。"); var delaytimenum =Math.round(Math.random()*10); delaytime = GM_getValue("delaytime", 100); sleep(delaytimenum*delaytime); submitLearn(chapternum); } } } //模拟学习 function submitLearn (chapterNum) { $.ajax({ type : "post", url : "/study/learn/"+chapterNum, data : null, async : false, success : function(data){ //console.log("章节:"+chapterNum+"学习完毕"); } }); } //开始全部练习题 function StartExercise () { var exerciseList = GM_getValue("exerciseList", null); exerciseBuild(exerciseList[0]['courseId'],exerciseList[0]['chapterId']); } //做习题 var indexexercise = fullurl.indexOf("exercise"); if(indexexercise>0){ var exerciseList = GM_getValue("exerciseList", null); var exercisenum = fullurl.substring(indexexercise+9); var xuefaexerciseurl ="/study/submitExercise/"+exercisenum; var answerjson={}; var answerTitlejson=GM_getValue("AnswerForTitle", {}); var isback2index = true; $(".item").each(function(){ var qid=$(this).attr("qid"); var answer=$(this).find(".answer").attr("val"); var answerTitleTempStr = $(this).find(".question-title").html(); var subStartIndex = answerTitleTempStr.indexOf("."); var subEndIndex = answerTitleTempStr.indexOf("<label"); var answerTitleStr = answerTitleTempStr.substring(subStartIndex,subEndIndex ).replace(/\s+/g,""); answerjson[qid]=answer; answerTitlejson[answerTitleStr] = answer; }); GM_setValue("AnswerForTitle", answerTitlejson); console.log(answerTitlejson); var delaytimenum =Math.round(Math.random()*80+20); delaytime = GM_getValue("delaytime", 100); sleep(delaytimenum*delaytime); $.ajax({ type : "post", url : xuefaexerciseurl, data : answerjson, async : false, success : function(data){ if(data.toString().indexOf('满分')>0){ for(var i=0;i<exerciseList.length-1;i++){ if(exercisenum==exerciseList[i]['chapterId']){ isback2index = false; exerciseBuild(exerciseList[i+1]['courseId'],exerciseList[i+1]['chapterId']); } } if(isback2index){ updateNotice("返回首页!","学习结束"); window.location.href= "http://xfks-study.gdsf.gov.cn/study/index"; } } } }); } //获取章节内容 function getChapterContent(chapterUrl){ var result= false; $.ajax({ type : "get", url : chapterUrl, data : null, async : false, success : function(data){ result = true; } }); return result; } //创建练习题 function exerciseBuild(courseId,chapterId){ jQuery.ajax({ url: "/study/exerciseBuild/"+courseId+"/chapter/"+chapterId, method:"post", data:null, success:function(data){ window.location.href = "/study/exercise/"+data; }, error:function(data){ startExercise = false; if(data.status == 400){ alert(data.responseText); }else{ alert("创建失败"); } } }) } function sleep(delay) { var start = (new Date()).getTime(); while ((new Date()).getTime() - start < delay) { continue; } } function updateNotice(noticeText,noticeTitle){ GM_notification({ text: noticeText, title: noticeTitle }); } /* if (typeof layer === 'undefined') { } else{ layer.msg('您的密码为初始密码,但我不建议修改密码!!!', { time: 1000, btn: ['确定'], icon:0, shade: [0.3,'#000',true], btn1: function() { return; } }); } */ var indexexam = fullurl.indexOf("exams"); if(indexexam>0) { var examnum = fullurl.substring(indexexam+6); var examurl = "/study/exams/"+examnum; var saveexamurl = "/study/saveAnswer/"+examnum; //alert(examurl); var allanserhasfind = false; var examarea = 'none'; var answerjson={}; var answerTitlejson=GM_getValue("AnswerForTitle", {}); var answerCount = 0; for (var x in answerTitlejson) { answerCount++; } if(answerCount==0){ alert("系统题库为空,请做一遍练习题,丰富题库!"); } console.log("题库数量为:"+answerCount+"条。"); var rightqidcount= 0; var wrongqidcount = 0; var AnswerString = ""; $(".item").each(function(){ var qid=$(this).attr("qid"); var answerTitleTempStr = $(this).find(".question-title").html(); var subStartIndex = answerTitleTempStr.indexOf("."); var answerTitleStr = answerTitleTempStr.substring(subStartIndex).replace(/\s+/g,""); //console.log(answerTitleStr); if (typeof totalAnswer[qid] === 'undefined') { if (typeof answerTitlejson[answerTitleStr] === 'undefined') { wrongqidcount++; $(this).css("background", "#ccc"); } else{ AnswerString+=qid+"="+answerTitlejson[answerTitleStr]+"&"; rightqidcount ++; } } else{ AnswerString+=qid+"="+totalAnswer[qid]+"&"; rightqidcount ++; } //answerjson[qid]=answer; }); if(wrongqidcount>0){ allanserhasfind = false; alert("共"+wrongqidcount+"条题目未找到答案,未找到答案的题目已变灰!"); } else{ allanserhasfind = true; } AnswerString=AnswerString.substring(0,AnswerString.length-1); if(allanserhasfind){ jQuery.ajax({ url:saveexamurl, method:"post", data: AnswerString, success:function(data, text, xhr){ if(xhr.status == 200){ alert("已找到全部题目答案,并保存答案成功,效果刷新页面可见!"); var issubmitanswer=confirm("是否自动提交答案?"); if(issubmitanswer){ jQuery.ajax({ url:examurl, method:"post", data: AnswerString, success:function(data, text, xhr){ if(xhr.status == 200){ window.location.href = '/study/exam'; }else{ alert(data); } }, error:function(data){ if(data.status == 400){ alert(data.responseText) }else{ alert("提交失败"); } } }) } }else{ alert(data); } }, error:function(data){ if(data.status == 400){ alert(data.responseText) }else{ alert("提交失败"); } } }) } } })();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址