forked from RounabhSahu/myperfectice_extension
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontentScript.js
54 lines (48 loc) · 1.92 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
/*
Author: Arijit Paria
Subscribe @tutoriex on youtube to get more such scripts
Note:
This script is free to use, do not pay anyone anything.
To modify or redistribute, kindly follow the license agreement strictly.
*/
//--------------------//
chrome.runtime.onMessage.addListener(function (message, sender, sendResponse) {
if (message.msg == "Sending Data") {
let ansKey = message.keys;
console.log(ansKey);
//time out for 2 secoond
setTimeout(function () {
document
.querySelector(
`#page-wrapper > p-student > app-learning-test > div.adaptive-question > div > div > div.adaptive-question-box.bg-white.p-1.ng-star-inserted > div:nth-child(2) > mcq-question > div > div.question-answers.mb-0 > div:nth-child(${
ansKey + 1
}) > div > div > div > label > span`
)
.click();
const pageWrapper = document.querySelector("#page-wrapper");
const saveAndNextButton = pageWrapper.querySelector(
"div.d-block.d-lg-none.fixed-bottom.ng-star-inserted a.btn-primary"
);
if (saveAndNextButton) {
saveAndNextButton.click();
}
}, 2000);
setTimeout(() => {
const nextbtn = document.querySelector(
"#page-wrapper > p-student > app-learning-test > div.adaptive-question > div > div > div.d-block.d-lg-none.fixed-bottom.ng-star-inserted>div.no-gutters> div:nth-child(2)> a.btn.btn-primary"
);
if (!nextbtn) {
document
.querySelector(
"#page-wrapper > p-student > app-learning-test > div.adaptive-question > div > div > div.d-block.d-lg-none.fixed-bottom.ng-star-inserted>div.no-gutters> div:nth-child(1)> a.btn.btn-primary"
)
.click();
} else {
nextbtn.click();
}
}, 3000);
}
if (message.msg == "start") {
chrome.runtime.sendMessage({ msg: "startPanel" });
}
});