职教云自动选题、答题并自动修改答题已用时间 脚本

笔者因某些原因,开发了此脚本,由于时间仓促,代码写的不尽人意,截止本文发出前仍可以使用。
如有需要,请自行修改源码对接你相应的题库接口就可以了
2020-11-1日,仅供学习交流,不得用于其他用途

// ==UserScript==
// @name         职教云自动答题
// @namespace    http://zjy.com
// @version      1.0
// @description  职教云 自动答题
// @author       Zhang Chenxi
// @match        https://zjy2.icve.com.cn/*
// @require      http://libs.baidu.com/jquery/2.0.0/jquery.min.js
// @grant        GM_xmlhttpRequest
// @grant        GM_download
// ==/UserScript==
 var result = "";
(function() {
  $(function(){
      function init_word(){
        var quesion_list = $(".e-q-q");
        var question_number = quesion_list.length;
        for(var i=0;i<question_number;i++){
            runAsync("q="+quesion_list[i].innerText,i);
        }
        var x = 15*question_number;//最长提交时间,单位s
        var y = 8*question_number;// 最短提交时间,单位s
        var rand = parseInt(Math.random() * (x - y + 1) + y);
        $("input[name='useTime']").val(rand);
        $("input[name='UseTime']").val(rand);
          $(".e-quest-header").append("<br><div style='color:red'>本次提交时间约为:"+ Math.round(rand/60)+"分"+(rand%60)+"秒<div>");
         // $(".e-quest-header").append("<br>—总之岁月漫长,然而值得等待—");
      }
      window.setTimeout( init_word, 2000 );
  });
  })();
  function get_option(true_answer,question_id){
    var option_list = $(".e-a-g ul")[question_id];
    var option_length = $(option_list).children().length;
    for(var i=0;i<option_length;i++){
      var answert_1 = $($(option_list).children()[i]).children(".ErichText.destroyTitleButton")[0].innerText;
      if(answert_1 == true_answer){
        $(option_list).children()[i].click();
        break;
      }else{
        if(i==option_length-1){
        var max = option_length-1;//最长提交时间,单位s
        var min = 0;// 最短提交时间,单位s
        var rand = parseInt(Math.random() * (max - min + 1) + min);
         $(option_list).children()[rand].click();
         var c = ["A","B","C","D"];
         console.log("第"+(question_id+1)+"题未找到答案,系统随机选择"+c[rand] );
        }
      }
    }
  }
  function runAsync(data_ry,question_id){
      GM_xmlhttpRequest({
          method: "POST",
          url: "",//接口
          data:data_ry,
          headers: {
              "Content-Type": "application/x-www-form-urlencoded;charset=utf-8"
          },
          onload: function(response) {
              get_option(response.responseText.trim(),question_id);
          }
      });
  }

使用效果:
在这里插入图片描述

  • 17
    点赞
  • 73
    收藏
    觉得还不错? 一键收藏
  • 23
    评论
评论 23
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值