机动车驾驶理论培训监控脚本

说明

当初学车时写的代码,不保证现在还能用。直接在浏览器的 Console 里粘贴代码执行即可,时间到浏览器会弹窗提示输验证码。

代码

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
(function(w) {
var Notification = w.Notification;
var Console = w.console;
var Timer = null;
var Title = '机动车驾驶理论培训';

if (!Notification) {
return w.alert('浏览器不支持 Notification');
}

var popNotice = function(title, body) {
var n = new Notification(title, {
body: body,
icon: 'http://hz.5u5u5u5u.com/qunle/images/footlogo.png',
requireInteraction: true
});
n.onshow = function() {
w.setTimeout(function() {
n.close();
}, 60 * 1000);
}
n.onclick = function() {
w.focus();
n.close();
};
return n;
};

var resetTimer = function() {
if (Timer) {
w.clearInterval(Timer);
Timer = null;
}
};

var setMonitor = function() {
if (w.courseware && w.courseware.ruleDto) {
w.courseware.ruleDto.mouseKeyboard = 0;
popNotice(Title, '已禁用鼠标监测!');
}
resetTimer();
Timer = w.setInterval(function() {
if (w.cast && w.randomTime) {
if (w.cast === (w.randomTime - 2)) {
popNotice(Title, '输验证码啦!');
} else if (w.cast >= w.courseware.classRemainTime) {
resetTimer();
popNotice(Title, '学时已达要求!');
} else {
Console.clear();
Console.info('距离输验证码还有 ' + (w.randomTime - w.cast) + ' 秒...');
}
}
}, 1000);
};

if (Notification.permission === 'granted') {
setMonitor();
} else if (Notification.permission !== 'denied') {
Notification.requestPermission(function(permission) {
if (permission === 'granted') {
setMonitor();
}
});
}
}(window));