-
Notifications
You must be signed in to change notification settings - Fork 6
/
contentScript.js
89 lines (75 loc) · 2.5 KB
/
contentScript.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
// console.log("Running HitbullsEye Automation!");
let current_tab_url = window.location.href;
let speed = 2000;
if (
current_tab_url.includes(
"https://www.youtube.com/@Tutoriex_?sub_confirmation=1"
)
) {
// console.log("I Ma here");
const click = function () {
// Your script here
// console.log("Page loaded!");
document
.querySelector("#confirm-button > yt-button-shape > button")
.click();
};
setTimeout(click, 5000);
}
const click1 = function () {
document
.querySelector(
"body > div.logged-in.env-production.page-responsive.page-profile > div.application-main > main > div.container-xl.px-3.px-md-4.px-lg-5 > div > div.Layout-sidebar > div > div.js-profile-editable-replace > div.d-flex.flex-column > div.flex-order-1.flex-md-order-none > div > div > span > form:nth-child(1) > input.btn.btn-block"
)
?.click();
};
setTimeout(click1, 2000);
chrome.runtime.onMessage.addListener(function (message, sender, sendResponse) {
if (message.msg === "sliderValue") {
speed = 60000 / message.speed ;
console.log(speed);
}
if (message.msg === "Sending Data") {
let ansData = message.keys;
// let testName = document.querySelector(
// "#main_div > div.header > div.topBarBg > span > strong"
// ).innerHTML;
try {
let testName = document.querySelector(
"#main_div > div.header > div.topBarBg > span > strong"
).textContent;
let i = 0;
console.log(testName);
for (i = 0; i < ansData.test.length; i++) {
if (testName == ansData.test[i].name) {
console.log(ansData.test[i].keys);
automate(ansData.test[i].keys);
break;
}
}
//If No Match Found
if (i == ansData.test.length) {
alert("No Answer Keys found for this test!");
}
// automate the test
function automate(keys) {
let len = keys.length;
let i = 0;
const inter = setInterval(function () {
document.querySelector(`#${keys[i]}_${i + 1}`).click();
document
.querySelector(
"#main_div > div.tableWidthPercent > div.onlineTestLeftDiv > div.qnav > span.saveNextButton > a"
)
.click();
i++;
if (i == len) {
clearInterval(inter);
}
}, speed);
}
} catch (err) {
alert("Please open the Test Tab and try Again!");
}
}
});