Skip to content

Commit 66accba

Browse files
wuwwuw
authored andcommitted
添加做作业脚本
1 parent 66fa4f5 commit 66accba

2 files changed

Lines changed: 80 additions & 0 deletions

File tree

dohomwork.js

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/**
2+
* Created by marker on 2017/6/25.
3+
*/
4+
5+
6+
/**
7+
* 该自动做作业脚本仅用于学习研究,未经作者同意不得用于商业用途。
8+
*
9+
*
10+
*
11+
* @author marker
12+
* @date 2017-06-25
13+
*/
14+
15+
16+
17+
18+
19+
/**
20+
* 自动做作业函数
21+
* @author marker
22+
* @param answerStr
23+
*/
24+
function doHomework(answerStr){
25+
var ans = answerStr.split(",");// 答案列表
26+
var questionNode = $("#tblDataList>tbody");
27+
var rows = questionNode.rows;
28+
29+
for(var i=0; i<rows.length; i++) {
30+
var item = rows[i];
31+
var right = ans[i];//正确答案 A =65
32+
if(!right){
33+
continue;// 不存在就继续走
34+
}
35+
var rightIndex = right.charCodeAt() - 65;
36+
// 答案里列表
37+
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]
38+
39+
40+
// 选中答案
41+
try{// 尝试选择判断题
42+
console.log(answerListNode);
43+
answerListNode.rows[rightIndex].children[0].children[0].click();
44+
}catch(e){}
45+
// 尝试选择单选题
46+
try{
47+
answerListNode.rows[rightIndex].children[0].children[0].click();
48+
}catch(e){}
49+
50+
}
51+
}
52+
53+
// 做作业吧
54+
doHomework("D,B,B,B,C,C,B,C,B,D,A,D,D,C,A,B,B,B,A,D");
55+
56+

homework.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/**
2+
* 该自动做作业脚本仅用于学习研究,未经作者同意不得用于商业用途。
3+
*
4+
*
5+
*
6+
* @author marker
7+
* @date 2017-06-25
8+
*/
9+
10+
var listTable = $("#_block_content_exam_1>form>table>tbody")
11+
var rows = listTable.rows;
12+
var results = [];
13+
for(var i=0; i<rows.length; i++){
14+
var item = rows[i];
15+
var text = item.children[1].children[1].children[0].children[1].children[0].children[1].innerText
16+
// "[参考答案:B]  分值:5"
17+
18+
var index_a = text.indexOf(":")+1;
19+
var index_b = text.indexOf("]");
20+
var result = text.substring(index_a, index_b);
21+
22+
results.push(result);
23+
}
24+
console.log(results.join(","))

0 commit comments

Comments
 (0)