forked from DRAGONMANU/chrome_IIT
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmoodle.js
59 lines (50 loc) · 1.4 KB
/
moodle.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
var body = document.body;
var textContent = body.textContent;
var n = textContent.search("Please ");
var myString = textContent.substring(n, n+40);
var splits = myString.split(' ', 10);
var add = textContent.search("Please add");
var enter1 = textContent.search("Please enter first");
var enter2 = textContent.search("Please enter second");
var subtract = textContent.search("Please subtract");
var nameValue = "100";
if(add!=-1)
{
nameValue = parseInt(splits[4],10)+parseInt(splits[6],10);
}
else if(subtract!=-1)
{
nameValue = parseInt(splits[4],10)-parseInt(splits[6],10);
}
else if(enter1!=-1)
{
nameValue = parseInt(splits[6],10);
}
else
{
nameValue = parseInt(splits[8],10);
}
var delayMillis = 10;
var userid = "";
chrome.storage.sync.get('username',function (data) {
userid=data.username;
});
var pass = "";
chrome.storage.sync.get('password',function (data) {
pass=data.password;
});
var auto = false;
chrome.storage.sync.get('auto',function (data) {
auto=data.auto;
});
var button = document.getElementById("loginbtn");
var m = textContent.search("Invalid login");
setTimeout(function() {
document.getElementsByName("username")[0].value = userid;
document.getElementsByName("password")[0].value = pass;
document.getElementById("valuepkg3").value = nameValue;
if(auto & m==-1)
button.click();
if(m!=-1)
alert("Please check your username and password in the extension settings");
}, delayMillis);