-
Notifications
You must be signed in to change notification settings - Fork 0
/
moodle-auto-login.js
43 lines (37 loc) · 1.17 KB
/
moodle-auto-login.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
// @Author: Abdur Rahman
// Moodle IIT Delhi Auto Login
console.log("********** Moodle Auto Login Running **********")
var textContent = document.body.textContent;
var num = textContent.search("Please ");
var foundString = textContent.substring(num, num+50);
console.log(foundString);
var splits = foundString.split(' ');
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 = 00;
if(add!=-1)
{
nameValue = parseInt(splits[4])+parseInt(splits[6]);
}
else if(subtract!=-1)
{
nameValue = parseInt(splits[4])-parseInt(splits[6]);
}
else if(enter1!=-1)
{
nameValue = parseInt(splits[6]);
}
else
{
nameValue = parseInt(splits[8]);
}
var delayTime = 1;
setTimeout(function() {
document.getElementById("valuepkg3").value = nameValue;
/* IMPORTANT - FILL the 3 lines below with your user ID & Password (Keep them in inverted commas!)*/
document.getElementById("username").value = "kerberos_id_here";
document.getElementById("password").value = "password_here";
document.getElementById('loginbtn').click();
}, delayTime);