-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcontent.js
135 lines (104 loc) · 2.71 KB
/
content.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
// taking care of all the animation
// function wait(ms){
// var start = new Date().getTime();
// var end = start;
// while(end < start + ms) {
// end = new Date().getTime();
// }
// }
function startAnimation()
{
for (i=10; i!=0; i--){for (m of document.getElementsByClassName("start-button")){
m.click();
}};
}
function activateDoubleSpeed()
{
let doubleSpeed = document.querySelectorAll('[aria-label="2x speed"]');
for (button of doubleSpeed){button.click()};
}
function solveAnimation()
{
//starting the animation
activateDoubleSpeed();
startAnimation();
setInterval(function() {
if(document.getElementsByClassName("start-button").length>0)
{
for(s of document.getElementsByClassName('start-button')) {s.click()};
}
else
console.log("Looks like we started all animations")
if(document.getElementsByClassName("play-button").length>0)
{
for (x of document.getElementsByClassName('play-button')) {x.click()};
}
else
console.log("Play isn't found");
}, 3000)
}
function solveMultipleChoice()
{
for (radio of document.querySelectorAll('input[type=radio]')) {radio.click()};
}
function solveShortAnswer()
{
for(var x=3; x>0; x--){
for (m of document.getElementsByClassName('show-answer-button') ){m.click()};
}
answers = document.getElementsByClassName('forfeit-answer');
while(answers.length===0)
{
for (m of document.getElementsByClassName('show-answer-button') ){m.click()};
answers = document.getElementsByClassName('forfeit-answer');
}
console.log(answers);
textBoxes = document.getElementsByClassName('zb-text-area');
//copying answers to textBoxes
for(var i = 0; i<answers.length;i++){
textBoxes[i].value = answers[i].innerText
}
// let something;
// for (textBox of textBoxes)
// {
// something = await $('#'+textBox.id).change();
// }
// for (textBox of textBoxes)
// {
// something = await $('#'+textBox.id).focus();
// }
// console.log(something)
// for (var checkButton=0; checkButton < document.getElementsByClassName('check-button').length; checkButton++)
// {
// document.getElementsByClassName('check-button')[checkButton].click();
// console.log("clicked check button");
// }
}
function solveAll()
{
solveAnimation();
solveMultipleChoice();
}
// content.js
chrome.runtime.onMessage.addListener(
function(request, sender, sendResponse) {
switch(request.message) {
case "solveAll":
solveAll();
console.log("got message:"+ request.message);
break;
case "solveAnimation":
solveAnimation();
break;
case "solveMC":
solveMultipleChoice();
break;
case "solveSA":
solveShortAnswer();
break;
default:
console.log("Caught unknown message: "+ request.message);
}
}
);
console.info("AutoZy Loaded")