1 Star 0 Fork 0

崔立军/答卷星

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
ajx.js 3.37 KB
一键复制 编辑 原始数据 按行查看 历史
崔立军 提交于 2022-01-17 20:50 . first commit
window.onload = function(){
if(window.location.href.indexOf("https://www.wjx.cn/wjx/join/complete.aspx")>-1){
window.location.href="https://www.wjx.cn/vj/PprjttC.aspx";
}
setTimeout(()=>{
startMain();
},3000)
}
//题目内容div
var survey = '';
//里面的列表
var fieldset1 = '';
var divQuestion = '';
var questionNum = 0;
var scrollTotal = document.body.scrollHeight-window.innerHeight
//函数入口
function startMain(){
console.log("fxxk");
survey = document.getElementById("ctl00_ContentPlaceHolder1_JQ1_surveyContent");
fieldset1 = document.getElementById("fieldset1");
divQuestion = document.getElementsByClassName("div_question");
//获取题目的长度
questionNum = divQuestion.length;
//console.log(questionNum);
answerQuestion(questionNum);
}
//某道题的选项ul列表标签
var radioUl = '';
var radioLi = '';
var firstA = '';
var answerType = ''
function answerQuestion(qn){
console.log("接收到"+qn)
let i = 0;
var exAws = setInterval(() => {
if(i==qn){
clearInterval(exAws);
//答卷完毕,准备提交
document.getElementById("submit_button").click();
setTimeout(() => {
if(document.getElementById("alert_box")){
document.getElementById("alert_box").getElementsByClassName("mainBgColor")[0].click();
setTimeout(() => {
document.getElementsByClassName("out-silder-circle")[0].click();
}, 1500);
}
}, 3000);
}
else{
radioUl = divQuestion[i].getElementsByClassName("ulradiocheck");
radioLi = divQuestion[i].getElementsByTagName("li");
answerType = divQuestion[i].getElementsByTagName("li")[0].getElementsByTagName("input")[0].getAttribute("type");
//console.log(answerType);
//console.log(i)
fillAnswer(i);
//console.log(radioUl)
i++;
}
}, 1000);
}
function fillAnswer(n){
var length = radioLi.length;
//console.log("答案有"+length+"个")
//判断单选还是多选
if(answerType=='radio'){
//如果是单选,随机选一个选项
var answerChoose = Math.round(Math.random()*(length-1));
console.log(answerChoose)
divQuestion[n].getElementsByTagName("li")[answerChoose].getElementsByTagName("a")[0].click();
}
else if(answerType=='checkbox'){
//如果是多选,先随机出要选几个答案,再随机选择
var answerNum = Math.ceil(Math.random()*length);
var answerArray = [];
var answerChoose;
console.log("答案有:"+answerNum+"")
for(let i = 0;i<answerNum;i++){
answerChoose = Math.round(Math.random()*(length-1));
console.log("-------------------")
console.log(answerArray)
console.log(answerChoose)
console.log("-------------------")
//防止两次随机到一样的选项
while(answerArray.indexOf(answerChoose)>-1){
answerChoose = Math.round(Math.random()*(length-1));
}
divQuestion[n].getElementsByTagName("li")[answerChoose].getElementsByTagName("a")[0].click();
answerArray.push(answerChoose)
}
}
window.scrollBy(0,scrollTotal/questionNum)
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/cui-lijun/answer-star.git
git@gitee.com:cui-lijun/answer-star.git
cui-lijun
answer-star
答卷星
master

搜索帮助

D67c1975 1850385 1daf7b77 1850385