Greasy Fork is available in English.

青书学堂 作业/考试-最新版(千万题库)-秒出答案

【注意】如果第一次答题答案不全,可以先查看一遍答案重新答案即可。本脚本包含自动搜集答案功能,请在作业或者考试的时候自觉点击查看答案,方便您下次遇到同样科目便能自动补全答案。若没选的即视为未匹配到正确答案。问题反馈QQ:1012507575

// ==UserScript==
// @name         青书学堂 作业/考试-最新版(千万题库)-秒出答案
// @namespace    http://tampermonkey.net/
// @version      1.5
// @description  【注意】如果第一次答题答案不全,可以先查看一遍答案重新答案即可。本脚本包含自动搜集答案功能,请在作业或者考试的时候自觉点击查看答案,方便您下次遇到同样科目便能自动补全答案。若没选的即视为未匹配到正确答案。问题反馈QQ:1012507575
// @author       QQ:1012507575
// @match        https://*.qingshuxuetang.com/*/Student/*
// @match        https://degree.qingshuxuetang.com/*/Student/ExamPaper*
// @match        https://degree.qingshuxuetang.com/*/Student/ExercisePaper*
// @match        https://degree.qingshuxuetang.com/*/Student/ViewQuiz*
// @match        https://*.qingshuxuetang.com/*/Student/ViewQuiz*
// @require      https://cdn.staticfile.org/jquery/1.8.3/jquery.min.js
// @require      https://cdn.bootcdn.net/ajax/libs/layer/3.1.1/layer.js
// @resource     layer http://cdn.bootcdn.net/ajax/libs/layer/3.1.1/theme/default/layer.css
// @grant        GM_xmlhttpRequest
// @grant        GM_addStyle
// @grant        GM_getValue
// @grant        GM_setValue
// @grant        GM_getResourceText
// @grant        GM_getResourceURL
// @grant        unsafeWindow
// @connect      *
// ==/UserScript==
GM_addStyle(GM_getResourceText('layer'));
GM_addStyle(".site-dir{display:none;}.site-dir li{line-height:26px;overflow:visible;list-style-type:disc;}.site-dir li a{display:block;text-decoration:none}.site-dir li a:active{color:#01AAED;}.site-dir li a.layui-this{color:#01AAED;}body .layui-layer-dir{box-shadow:none;border:1px solid #d2d2d2;}body .layui-layer-dir .layui-layer-content{padding:10px;}.site-dir a em{padding-left:5px;font-size:12px;color:#c2c2c2;font-style:normal;}");
GM_addStyle(".layui-layer-ico16,.layui-layer-loading.layui-layer-loading2{width:32px;height:32px;background:url(https://cdn.bootcdn.net/ajax/libs/layer/3.1.1/theme/default/loading-2.gif)no-repeat;}.layui-layer-ico{background: url(https://cdn.bootcdn.net/ajax/libs/layer/3.1.1/theme/default/icon.png) no-repeat;}");

(function() {
    'use strict';
    //TOKEN填入此处

    var TOKEN = localStorage.getItem("kktoken")
    var selfUrl = window.location.href;
    var tk = "";
    if(TOKEN){tk=TOKEN}
     var contentHtml = '<div style="padding:10px 10px;font-size:13px"><div style="padding:5px"><input type="text" name="kktoken" id="kktoken" required  lay-verify="required" placeholder="TOKEN填入此处" value="'+tk+'" autocomplete="off" class="layui-input">&nbsp;&nbsp;<button type="button" id="saveToken" class="layui-btn">&nbsp;&nbsp;保存&nbsp;&nbsp;</button>&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://item.taobao.com/item.htm?ft=t&id=743212100866" target="_blank" style="color:blue">点击购买TOKEN</a> <br/>剩余次数:<span id="times">0</span></div>'
    +' <table class="layui-table" style="width:100%;margin-top:30px">'
 +' <colgroup>'
 +'   <col width="30">'
  +'  <col width="200">'
  +'  <col>'
  +'</colgroup>'
 +' <thead>'
  +'  <tr>'
  +'    <th>序号</th>'
  +'    <th>标题</th>'
  +'    <th>答案</th>'
  +'  </tr> '
  +'</thead>'
  +'<tbody id="answerMain" style="font-size:11px">'
 +' </tbody>'
+'</table>'
     +'</div>';
    if(selfUrl.indexOf("sIndex")>=0||selfUrl.indexOf("ExamPaper")>=0||selfUrl.indexOf("ExercisePaper")>=0){
        layer.open({
            type: 1,
            title:'快考 - 青书学堂/作业/期末',
            skin: 'layui-layer-rim', //加上边框
            shade: false,
            area: ['420px', '650px'], //宽高
            closeBtn: 0,
            content: contentHtml
        });
    }
     

    setTimeout(function(){
    var questions = $(".question-detail-container")
    for(var i=0;i<questions.length;i++){
        $(questions[i]).show()
        var title = $(questions[i]).find(".question-detail-description").text().trim().replaceAll(" ","").replaceAll("  ","").replace(/\s+/g, "")
        if(title==null||title==""){
            title=$(questions[i]).find(".question-detail-description").find("img").eq(0).attr("src")
        }
        var answer = "";
        var ttt = $(questions[i]).find(".question-header-left").text()
        console.log(ttt)
        if(ttt.indexOf("问答题")>=0||ttt.indexOf("简答题")>=0||ttt.indexOf("填空")>=0||ttt.indexOf("名词")>=0||ttt.indexOf("论述")>=0||ttt.indexOf("写作")>=0||ttt.indexOf("未命名分区")>=0){
            answer = $(questions[i]).find(".question-detail-solution").eq(1).find(".question-detail-solution-text").text()
            console.log(title,answer)
            ajax(title,answer)
            continue;
        }
        var rightSelect = $(questions[i]).find(".question-detail-choice-solution").text()
         if(ttt.indexOf("判断题")>=0){
             rightSelect = $(questions[i]).find(".question-detail-choice-solution-text").eq(1).text()
            console.log(title,rightSelect)
            ajax(title,rightSelect)
            continue;
        }

        var options = $(questions[i]).find(".question-detail-options").find(".question-detail-option")
        

        if(rightSelect.indexOf("A")>=0){
            answer+=$(options[0]).find(".option-description-preview").text()+"#";
        }
        if(rightSelect.indexOf("B")>=0){
            answer+=$(options[1]).find(".option-description-preview").text()+"#";
        }
        if(rightSelect.indexOf("C")>=0){
            answer+=$(options[2]).find(".option-description-preview").text()+"#";
        }
        if(rightSelect.indexOf("D")>=0){
            answer+=$(options[3]).find(".option-description-preview").text()+"#";
        }
        if(rightSelect.indexOf("E")>=0){
            answer+=$(options[4]).find(".option-description-preview").text()+"#";
        }
        if(rightSelect.indexOf("F")>=0){
            answer+=$(options[5]).find(".option-description-preview").text()+"#";
        }
        if(rightSelect.indexOf("G")>=0){
            answer+=$(options[6]).find(".option-description-preview").text()+"#";
        }
        answer = answer.substring(0,answer.length-1)
        console.log(title,answer)
        ajax(title,answer)
    }
        
 },2000)
        function ajax(title,anser){
         if(title==""||anser==""){return}
         GM_xmlhttpRequest({
            //请求方式
             method : "POST",
            //请求的媒体类型
            //contentType: "application/json;charset=UTF-8",
            //请求地址
            url : "http://116.62.157.163:8080/question/set?title="+title+"&answer="+encodeURIComponent(anser),
            //请求成功
            onload: res=> {},
            //请求失败,包含具体的错误信息
            error : function(e){
                console.log(e.status);
                console.log(e.responseText);
            }
        });
       }

setTimeout(function(){
    if(selfUrl.indexOf("ViewQuiz")>=0){return}
    var questions = $(".question-detail-container")
    for(var i=0;i<questions.length;i++){
        $(questions[i]).show()
             sss($(questions[i]),i);
    }
        $(questions).show()
 },2000)


    async function sss(question,i){

        var title = $(question).find(".question-detail-description").text().trim().replaceAll(" ","").replaceAll("  ","").replace(/\s+/g, "")
        if(title==null||title==""){
            title=$(question).find(".question-detail-description").find("img").eq(0).attr("src")
        }
        var titleHtml = $(question).find(".question-detail-description").html();
        var options = $(question).find(".question-detail-options").find(".question-detail-option")
        GM_xmlhttpRequest({
                    //请求方式
                    method : "GET",
                    //请求的媒体类型
                    //contentType: "application/json;charset=UTF-8",
                    //请求地址
                    url : "http://116.62.157.163:8080/question/get?token="+TOKEN+"&title="+title,
                    //数据,json字符串
                    datatype: "json",
                    synchronous:    true,
                    //请求成功
                     headers: {
                         "Content-type": "application/json;charset=UTF-8"
                     },
                    onload: res=> {
                        var result = JSON.parse(res.response)
                        console.log(result);
                        if(result.code==0){
                            var anser = result.data.answer

                            if(anser==null||anser==""){
                                for(var j=0;j<options.length;j++){
                                    //$(options[j]).find("input").click()
                                }
                                return;
                            }
                            var bigtitle = $(question).find(".question-header-left").text()
                            if(bigtitle.indexOf("问答")>=0||bigtitle.indexOf("填空")>=0||bigtitle.indexOf("简答")>=0||bigtitle.indexOf("写作")>=0){
                                   $(question).find(".cke_wysiwyg_div").html(anser)
                            }
                            var ans = anser.trim().replaceAll(" ","").replaceAll(" ","").replaceAll("  ","").replace(" ","").split("#")

                            if($(question).find(".question-header-left").text().indexOf("判断题")>=0){
                                  if("正确|对|True|T|√|true".indexOf(anser)>=0){
                                     $(options[0]).find("input").click()
                                  }
                                if("错误|错|Flase|F|×|false".indexOf(anser)>=0){
                                     $(options[1]).find("input").click()
                                  }
                            }else{
                                for(var j=0;j<options.length;j++){
                                    var option = $(options[j]).find(".option-description").text().trim().replaceAll(" ","").replaceAll(" ","").replaceAll("  ","")
                                    for(var k=0;k<ans.length;k++){
                                        if(ans[k].trim().replaceAll(" ","").replaceAll(" ","").replaceAll("  ","")==option){
                                            $(options[j]).find("input").click()
                                        }
                                    }
                                }
                            }

                        }else{

                        }
                        var as = "";
                        $("#times").text(result.data.num)
                        if(result.code!=0){as = '<span style="color: orange;">'+result.msg+'</span>'}else{as='<span>'+result.data.answer+'</span>'}
                        var answerHtml =  '    <tr style="background:rgb(236, 245, 255);;border-collapse: collapse;border-collapse: separate;border: 1px solid #ccc; ">'
                                +'      <td>'+(Number(i)+1)+'</td>'
                                +'      <td>'+titleHtml+'</td>'
                                +'      <td>'+as+'</td>'
                                +'    </tr>';
                            $("#answerMain").append(answerHtml)
                    },
                    //请求失败,包含具体的错误信息
                    error : function(e){
                        console.log(e.status);
                        console.log(e.responseText);
                    }

                });
        console.log(title)
    }
    $("#saveToken").click(function(){
        var kktoken = $("#kktoken").val()
        localStorage.setItem("kktoken",kktoken)
        layer.msg("保存成功")
    })

    // Your code here...
})();