1 Star 0 Fork 0

Cedar/blog

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
mjusecond.js 5.75 KB
一键复制 编辑 原始数据 按行查看 历史
Cedar 提交于 2021-04-20 18:30 . update mjusecond.js.
(function(){const youxueyuan={$startBtn:null,$stopBtn:null,timer:null,init(){this.$startBtn=$('<button class="btn-hollow" style="z-index:99999;position:relative">开始刷课</button>');this.$stopBtn=$('<button class="btn-hollow" style="z-index:99999;position:relative">暂停刷课</button>');let $erviceMask=$('<div class="custom-service custom-service-mask"></div>');$('.custom-service').parent().append($erviceMask);$('.custom-service').eq(0).remove();$erviceMask.append(this.$startBtn).append(this.$stopBtn);this.$stopBtn.hide();this.bindEvent();log.init()},bindEvent(){this.$startBtn.click(()=>{this.logic();this.timer=setInterval(()=>{this.logic()},1500);this.$startBtn.hide();this.$stopBtn.show()});this.$stopBtn.click(()=>{clearInterval(this.timer);this.$stopBtn.hide();this.$startBtn.show();if($(".file-media").length>0){let $allVideos=$(".file-media");for(let i=0;i<$allVideos.length;i++){if($('.mejs__button.mejs__playpause-button button').eq(i).attr('title')=='Pause'){$('.mejs__button.mejs__playpause-button button')[i].click()}}}log.showLogs()})},logic(){if($('.modal.fade.in').length>0){switch($('.modal.fade.in').attr('id')){case'statModal':{$("#statModal .btn-hollow").eq(-1).click();break}case'alertModal':{if($("#alertModal .btn-hollow").length>0){$("#alertModal .btn-hollow").eq(-1).click()}else{$("#alertModal .btn-submit").click()}break}default:{log.addLog('出现了未知对话框')}}return}if($(".file-media").length>0){let $allVideos=$(".file-media");let i=0;for(;i<$allVideos.length;i++){if(!$("[data-bind='text: $root.i18nMessageText().finished']").get(i)){if($('.mejs__button.mejs__playpause-button button').eq(i).attr('title')=='播放'){console.log($('.mejs__button.mejs__playpause-button button').eq(i).attr('title'));var t=$("video");t.get(0).play();$(".mejs__speed-selector-input")[i*4].value=3.00;$(".mejs__speed-selector-input")[i*4].click();$('.mejs__button.mejs__speed-button button')[i].innerText='99999.00x'}break}}if(i==$allVideos.length){$('.next-page-btn.cursor').click()}return}if($('.question-setting-panel').length>0){let $submitBtn=$('.question-operation-area button').eq(0);if($submitBtn.text()=='重做'){$submitBtn.click();return}let parentId=$('.page-name.active').parent().attr('id').substring(4);let $questions=$('.question-element-node');for(let i=0;i<$questions.length;i++){respondent.answer(parentId,$questions.eq(i))}$submitBtn.click();setTimeout(()=>{$('.next-page-btn.cursor').click()},300);return}$('.next-page-btn.cursor').click()},};const respondent={parentId:null,questionId:null,$questionNode:null,answer(parentId,$questionNode,callback){this.parentId=parentId;this.$questionNode=$questionNode;this.questionId=this.$questionNode.find('.question-wrapper').attr('id').substring(8);let questionType=$questionNode.find('.question-type-tag').text().trim();switch(questionType){case'多选题':{this._answerMultiSelect();break}case'单选题':{this._answerSelect();break}case'判断题':{this._answerJudge();break}case'填空题':{this._answerInput();break}case'简答题':{this._answerSimpleQuestion();break}case'综合题':{break}default:{log.addLog('出现了未知题型')}}if(callback&&typeof callback=='function')callback()},_answerMultiSelect(){let $selected=this.$questionNode.find('.checkbox.selected');for(let i=0;i<$selected.length;i++){$selected.eq(i).click()}let $emptySelected=this.$questionNode.find('.checkbox');let answerArray=this._syncGetAnswer().correctAnswerList;for(let i=0;i<answerArray.length;i++){let index=answerArray[i].charCodeAt()-'A'.charCodeAt();$emptySelected.eq(index).click()}},_answerSelect(){let $emptySelected=this.$questionNode.find('.checkbox');let answerArray=this._syncGetAnswer().correctAnswerList;for(let i=0;i<answerArray.length;i++){let index=answerArray[i].charCodeAt()-'A'.charCodeAt();$emptySelected.eq(index).click()}},_answerJudge(){let questionAnswer=this._syncGetAnswer().correctAnswerList[0];if(questionAnswer){this.$questionNode.find('.choice-btn.right-btn').click()}else{this.$questionNode.find('.choice-btn.wrong-btn').click()}},_answerInput(){let $emptyInput=this.$questionNode.find('.blank-input');let inputAnswers=this._syncGetAnswer().correctAnswerList;for(let i=0;i<inputAnswers.length;i++){$emptyInput.eq(i).val(inputAnswers[i])}},_answerSimpleQuestion(){let $emptyInput=this.$questionNode.find('.form-control');let inputAnswers=this._syncGetAnswer().correctAnswerList;for(let i=0;i<inputAnswers.length;i++){let answerText=inputAnswers[i].replace(/【答案要点】/g,'');$emptyInput.eq(i).val(answerText);$emptyInput.change()}},_syncGetAnswer(){return $.ajax({url:'https://api.ulearning.cn/questionAnswer/'+this.questionId+'?parentId='+this.parentId,async:false,error:()=>{log.addLog('请求答案接口出错')}}).responseJSON}};const log={logs:'',$modal:$(`<div class="modal"id="alertModal"tabindex="-1"role="dialog"style="display: none;background-color:rgba(0,0,0,.5)"><div class="modal-dialog"role="document"style="width:800px;margin-top:20px"><div class="modal-content"><i class="iconfont close-btn log-close-btn"data-dismiss="modal"aria-label="Close">?</i><div class="modal-image"><img src="./img / incomplete.png "></div><div class="modal - body "><div class="modal - info "><h4>本次刷课出现了意外情况,请将本提示截图并联系作者!</h4><div class="content log - content "style="text - align: left "></div></div><div class="modal - operation "><button class="btn - submit log - close - btn "type="button ">我明白了</button></div></div></div></div></div>`),init(){$('body').append(this.$modal);this.$modal.find('.log-close-btn').click(()=>{this.$modal.hide()})},addLog(info){this.logs+='<span>时间:'+new Date().toJSON()+' 信息:'+info+'</span><br>'},showLogs(){if(this.logs){this.$modal.find('.log-content').empty();this.$modal.find('.log-content').append($('<div>'+this.logs+'</div>'));this.$modal.show()}}};youxueyuan.init()})();
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
HTML/CSS
1
https://gitee.com/cedar_ing/blog.git
[email protected]:cedar_ing/blog.git
cedar_ing
blog
blog
master

搜索帮助