最近导员通知我们全体非毕业班级要做一个实验室安全考试系统,打开系统长这个样子,我点击考试

QQ截图20180624163725.png

什么?!!?还要安全练习,那就练习吧。什么?!!?还要100道题

QQ截图20180624163750.png

好难做呀~哎我发现旁边有个在线学习,要不我先学习会儿提高下姿势再来练习

QQ截图20180624163809.png

随便选一个院点进去

QQ截图20180624163852.png

竟然有答案!??! 要不我弄个题库然后自动答题?

说干就干

拿起刚学一两天的Jquery复制粘贴就一把梭

一共又三种题型 单选|多选|判断 下面以单选题为例

 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

function fuckOne(){

			var fuck1 = new Object();

			var reg = '/\d+、/'

			$('table[id=DataGridA] tbody tr').each(function(index, el) {

				var key = $(this).find('td table tr:first td span').text().replace(reg,"");

				var sel = $(this).find('td table tr:nth(3) td span').text();

				var value = null;

				if(sel=="A") value = $(this).find('table[id$=RBLAData] tbody tr td:nth(0) label').text();

				else if(sel=="B") value = $(this).find('table[id$=RBLAData] tbody tr td:nth(1) label').text();

				else if(sel=="C") value = $(this).find('table[id$=RBLAData] tbody tr td:nth(2) label').text();

				else value = $(this).find('table[id$=RBLAData] tbody tr td:nth(3) label').text();

				fuck1[key]=value;

				console.log(key+" "+value);

				console.log(key)

			});

			var data = JSON.stringify(fuck1)

			$.post('https://www.heeeepin.com/test1.php',{'data':data}, function(data, textStatus, xhr) {

					console.log("success");

				});

		}

将提取出来的题目和答案以json形式发往我的服务器然后存下来,这样我就有了一个选择题的题库,当然只是一个院的题库

一不做二不休干脆将所有院的题都提取出来,10分钟后我就有了考试平台所有题的题库

突然想到我是来做练习的不是当免费劳动力提取题库的

既然题库都有了能不能让他自动练习呢?果然懒是第一生产力

  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
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191

function testfuckOne(){



			$.get('https://www.heeeepin.com/json.php', function(data) {

				var s = JSON.parse(data);

				$('table[id$=DataGridA] tbody tr').each(function(index, el) {

					var question = $(this).find('td table tr:nth(0) td span').text().replace(/\d+ 、/g,"");;

					console.log(question);

					if(s[question]){

						if(s[question] instanceof Object){

							for(x in s[question]){

								$(this).find('td table tbody tr:nth(2) td table[id$=RBLBData] tbody tr').each(function(index, el) {

									//如果选项和题目相等 则选中!

									if($(this).find('td label').text().indexOf(s[question][x])!=-1){

										$(this).find('input:checkbox').attr('checked', 'checked');

									}

								});

							}

						}else{

							if(s[question]=="正确"){

								$(this).find('table[id$=RBLCData]').find('input:radio').eq(0).attr('checked', 'checked');	

							}else if(s[question]=="错误"){	

								$(this).find('table[id$=RBLCData]').find('input:radio').eq(1).attr('checked', 'checked');	

							}else{

								$(this).find('table[id$=RBLAData] tbody tr').each(function(index, el) {

									if($(this).find('td label').text().indexOf(s[question])!=-1){

										$(this).find('input:radio').attr('checked', 'checked');

									}	

								});

							}

							console.log(s[question]);

						}	

					}

				});

			});

			//提交

			setTimeout(function(){$('input[id=ctl00_ContentPlaceHolder1_btnOk]').click();},5000);

			//下一页

			$('input[id=ctl00_ContentPlaceHolder1_btnNext]').click();

		}

​```javascript

## `js`版自动练题就此诞生,又花了十来分钟搞定了100到练习题,终于可以开始我的考试了!!!!





----------



## 考试?!!? 考什么试  `Jquery`都学会了谁还考试啊

![fina.gif][5]



## 一键考试脚本

[Github欢迎Star][6]

​```javascript

var importJs=document.createElement('script');  

	importJs.setAttribute("type","text/javascript"); 

	importJs.setAttribute("src", "https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"); 

	document.getElementsByTagName("head")[0].appendChild(importJs);

setTimeout(fuck,1000);

function fuck(){

	$.get('https://raw.githubusercontent.com/ghosx/git/master/json.json', function(data) {

		console.log("get data success");

		var s = JSON.parse(data);

		$('table[id$=DataGridA] tbody tr').each(function(index, el) {

			var question = $(this).find('td tbody tr:nth(0) td span').text().replace(/\d+ 、/g,"");

			console.log(question);

			if(s[question]){

				console.log(s[question]);

				var fuck1 = $(this).find('table[id$=RBLAData] tr td:nth(0) label');

				var fuck2 = $(this).find('table[id$=RBLAData] tr td:nth(1) label');

				var fuck3 = $(this).find('table[id$=RBLAData] tr td:nth(2) label');

				var fuck4 = $(this).find('table[id$=RBLAData] tr td:nth(3) label');

				if(fuck1.text().indexOf(s[question])!=-1){

					$(this).find('table[id$=RBLAData] tbody tr input:radio').eq(0).attr('checked', 'checked');	

				}else if(fuck2.text().indexOf(s[question])!=-1){

					$(this).find('table[id$=RBLAData] tbody tr input:radio').eq(1).attr('checked', 'checked');	

				}else if(fuck3.text().indexOf(s[question])!=-1){

					$(this).find('table[id$=RBLAData] tbody tr input:radio').eq(2).attr('checked', 'checked');	

				}else if(fuck4.text().indexOf(s[question])!=-1){

					$(this).find('table[id$=RBLAData] tbody tr input:radio').eq(3).attr('checked', 'checked');	

				}

			}

		 });

		$('table[id$=DataGridC] tbody tr').each(function(index, el) {

			var que = $(this).find('span[id$=labCDataTitle]').text().replace(/\d+ 、/g,"");;

			console.log(que);

			if(s[que]){

				console.log(s[que]);

				if(s[que]=="正确"){

					$(this).find('table[id$=RBLCData] tr td:nth(0) input:radio').attr('checked', 'checked');

				}else if(s[que]=="错误"){

					$(this).find('table[id$=RBLCData] tr td:nth(1) input:radio').attr('checked', 'checked');

				}

			}

		});

	});

	alert("别呼吸~点击确定后倒数5秒奇迹将会发生")

}

总结

本来不到1小时搞定的答题,而我花了10小时写代码+用了10分钟装逼

亏大发了

西安理工大学实验室安全考试一键考试脚本(造福学妹)Github欢迎Star

西安理工大学实验室安全考试一键考试脚本(造福学妹)Github欢迎Star

西安理工大学实验室安全考试一键考试脚本(造福学妹)Github欢迎Star