-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSafetyEdu_AutoClick.user.js
68 lines (64 loc) · 2.42 KB
/
SafetyEdu_AutoClick.user.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
// ==UserScript==
// @name SafetyEdu_AutoClick
// @namespace http://www.safetyedu.org/
// @version 0.1
// @description 연구실 안전교육 자동클릭
// @author BaeSeoyeon(bsy0317)
// @match http://www.safetyedu.org/Contents/IMGT*
// @icon https://www.google.com/s2/favicons?sz=64&domain=safetyedu.org
// @grant none
// ==/UserScript==
(function() {
var quizOk = false;
/*Confrim, Alert 함수의 반환값이 항상 true -> 자동확인*/
var realConfirm = window.confirm;
var realAlert = window.alert;
window.confirm = function() {
window.confirm = realConfirm;
return true;
};
window.alert = function() {
window.alert = realAlert;
return true;
};
/*END*/
/*비동기 대기 함수*/
function sleep(sec) {
return new Promise(resolve => setTimeout(resolve, sec * 1000));
}
/*END*/
/*퀴즈 선택 폼*/
async function check_quiz(){
var isQuiz = chapterInfo[this.nowPageNum-1].script[0].indexOf('퀴즈') == -1 ? false:true;
if(isQuiz && !quizOk){
var quizAll = document.querySelectorAll(".quiz");
totalQCnt = quizAll.length; // 전체 문항수
for (var i=0; i<quizAll.length; i++) {
initQuiz(quizAll[i]);
var quizStartBtn = document.querySelector(".quizStartBtn");
quizStartBtn.dispatchEvent(new Event("click"));
this.checkValue = document.querySelectorAll('div.quiz')[0].attributes[1].value;
document.querySelectorAll('.correctBtn')[0].dispatchEvent(new Event("click"));
document.querySelectorAll('.nextQuizBtn')[0].dispatchEvent(new Event("click"));
}
quizOk = isQuiz;
await sleep(10); //데이터 전송까지 잠시 대기
}
}
/*END*/
async function click_next() {
var nowTime = new Date().getTime();
var gapTime = parseInt((nowTime - prevTime) / 1000);
console.log("Now_gapTime:" + gapTime);
console.log("Complete_gapTime:" + Math.floor(duration));
if (gapTime >= Math.floor(duration)) {
await sleep(3); //데이터 전송까지 잠시 대기
let event = new Event("mousedown");
this.nextPageBtn.dispatchEvent(event);
}
}
setInterval(function timeout() {
check_quiz();
click_next();
}, 200);
})();