-
Notifications
You must be signed in to change notification settings - Fork 1
/
wayfortime.js
45 lines (40 loc) · 1.72 KB
/
wayfortime.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
function injectionScript(){
const [separatedMin, separatedSec] = document.querySelector("#main-container > div.main-content > div > div.page-content > div > div > div:nth-child(3) > div > div.table-header.bolder > span.badge.pull-right").innerHTML.split(' ')[19].split(':')
const computedMinSec = ((+separatedMin) * 60 + +separatedSec)
function shouldWait() {
const timer = +(document.getElementById('TEST_ELAPSED_TIME').value)
if(isNaN(timer)) return false;
return timer < computedMinSec
}
// mock function
function SaveTest(answerData) {
var url = "/StudentStudy/TestSaveNext";
if(shouldWait()) {
beneduAlertOkWarning('아직 최소풀이시간을 넘지 않았습니다.');
return
}
$.ajax({
url: url,
data: {
inputData : answerData,
beginData : $("#IBU_BEGIN_DATE").val(),
beginTime : $("#IBU_BEGIN_TIME").val()
},
type: 'POST',
success: function (data) {
if (data.item.RESULT < 0) {
beneduAlertOkWarning('답안을 제출하는 과정에서 오류가 발생하였습니다.');
return false;
} else if (data.item.RESULT = 0) {
beneduAlertOkWarning('답안 데이터가 바르지 않아 답안을 제출을 실패하였습니다.');
return false;
}
gotoResult();
return;
}
});
}
}
const injector = document.createElement('script')
injector.innerHTML = injectionScript.toString().slice(27, -1)
document.body.appendChild(injector)