传智播客自动搜题

try to take over the world!

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         传智播客自动搜题
// @namespace    http://stu.ityxb.com/writePaper/busywork/*
// @version      3
// @description  try to take over the world!
// @author       广东东软学院林鑫松同学
// @match        http://stu.ityxb.com/writePaper/busywork/*
// @grant        GM_xmlhttpRequest
// @connect      *
// ==/UserScript==



var questionObj;
var radioDiv;
var total = 0;//题目总数
var index = 0;//搜题索引
window.onload = function(){
questionObj = document.getElementsByClassName("question-title-box");
total = questionObj.length;
find(questionObj[index].innerText);




var bgdiv = document.getElementById("writeQuestion");
bgdiv.style.background = "url('https://s1.ax1x.com/2020/10/09/0BX4xI.png')";


}
   



function find(q){
        GM_xmlhttpRequest({
            method: 'POST',
            url: 'http://api.902000.xyz:88/wkapi.php',
            headers: {
                'Content-type': 'application/x-www-form-urlencoded'
            },
            data: 'q='+ encodeURIComponent(q),
            timeout: 2000,
            onload:function(xhr)
            {
                var str = xhr.responseText;
                console.log(index+","+str);
                var open = str.indexOf("answer");
                str = str.substring(open);
                open = str.indexOf("answer") + 9;
                var end = str.indexOf(",") - 1;
                var ans = str.substring(open,end);
                questionObj[index].innerText += "答案:"+ans;
                questionObj[index].style.color = "red";
                questionObj[index].style.fontSize = "28px";
                if(index < total - 1)
                {
                  setTimeout(function (){
                      index = index + 1;
                      find(questionObj[index].innerText);
}, 1000);
                 
                }


            }
        })
    }