-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
59 lines (55 loc) · 2.07 KB
/
script.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
(function () {
if (document.querySelector('button[type="submit"]').offsetParent !== null) {
alert("Please submit the test first!")
return
}
let form = Array.prototype.slice.call(document.getElementsByClassName("grafeon-generate-test")[0].children)
let flag = false
let n = []
form.forEach(el => {
if (!flag){
if (el.tagName.toLowerCase() == "h2"){
flag = true
}
return
}
if (el.tagName.toLowerCase() == "input"){
flag = false
}
n.push(el)
})
n.shift()
n = n.filter(el => el.tagName.toLowerCase() == "div")
let res = {}
for (let i = 0; i < n.length; i++){
res[i] = {}
let nx = Array.prototype.slice.call(n[i].getElementsByClassName("yesky_popover"))
for (let j = 0; j < nx.length; j++){
res[i][j] = nx[j].dataset.content
}
}
let els = Array.prototype.slice.call(document.getElementsByClassName("correct wrong"))
if (els.length > 0){
let parents = {}
els.forEach(el => {
if (!Object.keys(parents).includes(el.parentElement.parentElement.children[0].children[0].children[0].innerText)){
parents[el.parentElement.parentElement.children[0].children[0].children[0].innerText] = []
}
parents[el.parentElement.parentElement.children[0].children[0].children[0].innerText].push(el)
})
count = Object.keys(res).length - (Object.keys(res[Object.keys(res).length-1]).length==0?1:0)
Object.keys(parents).forEach(key => {
res[count] = {}
for (let i=0;i<parents[key].length;i++){
res[count][i] = `Správne odpovede: ${parents[key][i].innerText}`
}
count++;
})
}
let dl = window.document.createElement('a');
dl.href = window.URL.createObjectURL(new Blob([JSON.stringify(res,undefined,2)], {type: 'text/plain'}));
dl.download = 'odpovede.txt';
document.body.appendChild(dl)
dl.click();
document.body.removeChild(dl)
}())