This repository has been archived by the owner on Jul 5, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
SuperTræner.user.js
73 lines (64 loc) · 2.94 KB
/
SuperTræner.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
69
70
71
72
73
// ==UserScript==
// @name afrundingAfTalBot
// @namespace http://tampermonkey.net/
// @require https://ajax.googleapis.com/ajax/libs/jquery/1.6.0/jquery.min.js
// @version 1.0
// @description Løse Gang med 0 Opgaver
// @author LaZZe ( https://github.com/Janbuller )
// @match https://www.matematikfessor.dk/adaptive_test/index/*
// @grant none
// @require https://smtpjs.com/smtp.js
// @require https://unpkg.com/mathjs@4.1.1/dist/math.min.js
// ==/UserScript==
var Opgave;
function init() {
Opgave = SkafOpgave();
switch(Opgave) {
case "topic:afrunding-af-tal-96":
setInterval(function() {Afrunding()}, 100);
break;
case "topic:reduktion-med-tal-86":
setInterval(function() {ReduktionMedTal()}, 100);
break;
}
}
function SkafOpgave() {
return window.location.pathname.slice(21, window.location.pathname.length);
}
function ReduktionMedTal() {
var Reducer = document.getElementsByClassName("questionText")[0].children[0].innerText.slice(0, -11).match(/[\d,()+−:⋅]+/g).join("");
Reducer = Reducer.replace("+", "+");
Reducer = Reducer.replace("−", "-");
Reducer = Reducer.replace(":", "/");
Reducer = Reducer.replace("⋅", "*");
Reducer = math.eval(Reducer);
SendSvar(Reducer);
}
function Afrunding() {
var Afrund = document.getElementsByClassName("questionText")[0].children[0].innerText.slice(0, -11).match(/[\d,]*\d+/g).join("").slice(0, -1);
var AfrundMed = document.getElementsByClassName("questionText")[0].children[0].innerText.slice(0, -11).match(/[\d,]*\d+/g).join();
AfrundMed = AfrundMed[AfrundMed.length -1];
var Afrundet = Afrund.replace(",", ".");
Afrundet = parseFloat(Afrundet).toFixed(AfrundMed);
Afrundet = Afrundet.replace(".", ",");
SendSvar(Afrundet);
}
function SendSvar(svar) {
if (document.getElementsByClassName("questionText")[0].parentNode.children[1] != "[object HTMLUListElement]") {
document.getElementsByClassName("answerInput")[0].value = svar;
} else if (document.getElementsByClassName("questionText")[0].parentNode.children[1] == "[object HTMLUListElement]") {
for (var i = 0; i < document.getElementsByClassName("questionText")[0].parentNode.children[1].children.length; i++) {
if (document.getElementsByClassName("questionText")[0].parentNode.children[1].children[i].innerText.slice(0, -10) == svar) {
document.getElementsByClassName("questionText")[0].parentNode.children[1].children[i].click();
} else if (i == document.getElementsByClassName("questionText")[0].parentNode.children[1].children.length) {
document.getElementsByClassName("questionText")[0].parentNode.children[1].children[0].click();
}
}
}
try {
document.getElementsByClassName("big primary")[0].click()
} catch(error) {
console.log("error: " + error);
}
}
init();