-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathauto-learn.js
44 lines (39 loc) · 1.51 KB
/
auto-learn.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
"use strict";
const _log = console.log;
console.log = function() {
_auto(arguments);
return _log.apply(console, arguments);
};
let toListen = [
"changes",
"audioCompleteHandler",
"QuizDirective",
"this.model.isAudioCompleted()",
"doc",
"this.savesInQueue",
];
let _auto = (args) => {
const catched = args[0] && typeof args[0] === "string" && toListen.includes(args[0].split(" ")[0])
if (catched) {
_log("--> auto", "possible action detected, wait the UI", args[0]);
setTimeout(() => {
if (!document.getElementById("btn-agree").disabled) {
_log("--> auto", "found: agree");
document.getElementById("btn-agree").click();
} else if (!document.getElementById("next-btn").disabled) {
_log("--> auto", "found: next");
document.getElementById("next-btn").click();
} else if (document.querySelector('.option-con.enabled:not(.visited):not(.selected)')) {
_log("--> auto", "found: option to click");
setTimeout(() => document.querySelector(".option-con.enabled:not(.visited):not(.selected)").click());
} else if (document.querySelector(".btn.resource-btn.btn-primary")) {
_log("--> auto", "found: document to click");
setTimeout(() => document.querySelector(".btn.resource-btn.btn-primary").click());
} else {
_log("--> auto", "nothing found");
}
});
} else {
_log("--> auto", "NO next step detected", args);
}
};