-
Notifications
You must be signed in to change notification settings - Fork 7
/
dohomwork.js
100 lines (68 loc) · 2.88 KB
/
dohomwork.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/**
* Created by marker on 2017/6/25.
*/
/**
* 该自动做作业脚本仅用于学习研究,未经作者同意不得用于商业用途。
*
*
*
* @author marker
* @date 2017-06-25
*/
/**
* 自动做作业函数
* @author marker
* @param answerStr
*/
function doHomework(answerStr){
var ans = answerStr.split("|");// 答案列表
var questionNode = $("#tblDataList>tbody");
var rows = questionNode.rows;
for(var i=0; i<rows.length; i++) {
var item = rows[i];
var right = ans[i];//正确答案 A =65
if(!right){
continue;// 不存在就继续走
}
console.log(right);
if(right.length <= 1) {// 单项选择
console.log(i+".单选题:"+right);
var rightIndex = right.charCodeAt() - 65;// 0开始
// 答案里列表
var answerListNode = item.children[0].children[0].children[0].children[0].children[1].children[1].children[0].children[1].children[0].children[0].children[0].children[0]
if(answerListNode.children.length == 1){
// 选中答案
try{// 尝试选择判断题/单选题
if(rightIndex == 0){
answerListNode.children[0].children[0].children[0].click();
} else if(rightIndex == 1){
answerListNode.children[0].children[3].children[0].click();
} else if(rightIndex == 2){
answerListNode.children[0].children[6].children[0].click();
} else if(rightIndex == 3){
answerListNode.children[0].children[9].children[0].click();
}
}catch(e){}
}else{//
// 选中答案
try{// 尝试选择判断题/单选题
answerListNode.rows[rightIndex].children[0].children[0].click();
}catch(e){}
}
}else{// 多选题
console.log(i+".多选题:"+right);
for(var j=0;j<right.length; j++){
var crooet = right[j];
var rightIndex = crooet.charCodeAt() - 65;
// 答案里列表
var answerListNode = item.children[0].children[0].children[0].children[0].children[1].children[1].children[0].children[1].children[0].children[0].children[0].children[0]
// 选中答案
try{// 尝试选择判断题
answerListNode.rows[rightIndex].children[0].children[0].click();
}catch(e){console.log(e)}
}
}
}
}
// 做作业吧
doHomework("AB|ABCD|C|B|D|B|D|ABD|C|ABC|ABD|ABCD|ABCD|A|ACD|B|C|ABCD|ABCD|C");