Skip to content

Commit

Permalink
Merge pull request #125 from vishal-lokare/update
Browse files Browse the repository at this point in the history
Added 19,20,21 batches 4th sem
  • Loading branch information
vishal-lokare authored Feb 11, 2022
2 parents 866ad9b + 3ec721a commit 6a34fc6
Show file tree
Hide file tree
Showing 8 changed files with 1,471 additions and 307 deletions.
1,551 changes: 1,375 additions & 176 deletions backup.json

Large diffs are not rendered by default.

88 changes: 0 additions & 88 deletions full_page.html

This file was deleted.

24 changes: 11 additions & 13 deletions logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,25 @@ chrome.runtime.sendMessage('getPassword', (password) => {

$(document).ready(function () {
var url = window.location.href;
if (url == 'https://lms.iiitkottayam.ac.in/')
if (url == 'https://lms.iiitkottayam.ac.in/' || url == 'https://lmsone.iiitkottayam.ac.in/')
document.getElementsByClassName('btn-login')[0].click();

if (url == 'https://lms.iiitkottayam.ac.in/login/index.php' || url == 'https://lms.iiitkottayam.ac.in/login/index.php/#') {
if (url == 'https://lms.iiitkottayam.ac.in/login/index.php' || url == 'https://lms.iiitkottayam.ac.in/login/index.php/#' || url == 'https://lmsone.iiitkottayam.ac.in/login/index.php' || url == 'https://lmsone.iiitkottayam.ac.in/login/index.php/#') {
document.getElementById('username').value = replaceusername;
document.getElementById('password').value = replacepassword;
document.getElementsByClassName('btn btn-primary btn-block mt-3')[0].click();
}


if (url.includes('?reason=AutoJoomer')){
if (url.includes('?reason=AutoJoomer')) {
var btn = document.getElementById("join_button_input");

var timerId = setInterval(function(){
if(btn){
btn.click();
clearInterval(timerId);
}
else{
btn = document.getElementById("join_button_input");
}

var timerId = setInterval(function () {
if (btn) {
btn.click();
clearInterval(timerId);
} else {
btn = document.getElementById("join_button_input");
}
}, 1000);
}
})
14 changes: 10 additions & 4 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
{
"name": "AutoJoomer",
"version": "2.2.1",
"version": "2.3",
"manifest_version": 2,
"icons": {
"16": "icon.png",
"48": "icon.png",
"128": "icon.png"
},
"permissions": [
"tabs"
],
Expand All @@ -23,13 +28,14 @@
"matches": [
"https://lms.iiitkottayam.ac.in/",
"https://lms.iiitkottayam.ac.in/login/index.php",
"https://lms.iiitkottayam.ac.in/login/index.php/#",
"https://lms.iiitkottayam.ac.in/mod/bigbluebuttonbn/*"
"https://lms.iiitkottayam.ac.in/login/index.php/*",
"https://lms.iiitkottayam.ac.in/mod/bigbluebuttonbn/*",
"https://lmsone.iiitkottayam.ac.in/*"
],
"js": [
"jquery.js",
"logger.js"
]
}],
"content_security_policy": "script-src 'self' https://www.vishal-lokare.co https://www.googleapis.com https://*.firebasedatabase.app; object-src 'self'; connect-src 'self' wss://*.firebasedatabase.app https://www.vishal-lokare.co;"
}
}
19 changes: 15 additions & 4 deletions popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
color: white;
background: none;
border: 0;
width: fit-content;
}

select:focus {
Expand All @@ -55,7 +56,7 @@

label {
color: white;
font-size: 110%;
font-size: 100%;
}

.switch {
Expand Down Expand Up @@ -130,11 +131,22 @@
<input id="password" type="password" placeholder="Enter LMS password...">
<br><br>
<center>
<select name="year" id="year">
<option value="" style="color: grey;" selected disabled>Year</option>
<option value="2019">2019</option>
<option value="2020">2020</option>
<option value="2021">2021</option>
</select>
<select name="branch" id="branch">
<option value="null" style="color: grey;" selected disabled>Select Branch</option>
<option value="" style="color: grey;" selected disabled>Branch</option>
<option value="C">CSE</option>
<option value="E">ECE</option>
</select>
<select name="batch" id="batch">
<option value="" style="color: grey;" selected disabled>Batch</option>
<option value="1">1</option>
<option value="2">2</option>
</select>
<br><br>
<label for="confirmation">Confirmation Before Joining Classes ? </label>

Expand All @@ -146,9 +158,8 @@
</label>
<br><br>
<button type="button" id="button">SAVE</button> <br><br>
<button type="button" id="fpage">Open Full page</button>
</center>
</div>
</body>

</html>
</html>
40 changes: 30 additions & 10 deletions popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,24 @@ var password;
var branch;
var confirmation;
window.onload = function () {
username = document.getElementById("username");
password = document.getElementById("password");
branch = document.getElementById("branch");
confirmation = document.getElementById("confirmation");
populator();
document.getElementById("button").addEventListener("click", saveValues);
document.getElementById("button").innerHTML = "SAVE";
document.getElementById("button").disabled = false;
branch.disabled = true;
batch.disabled = true;
document.getElementById("year").addEventListener("change", function () {
branch.getElementsByTagName("option")[1].selected = true;
batch.getElementsByTagName("option")[0].selected = true;
if (year.value == "2019") {
branch.disabled = true;
batch.disabled = true;
} else {
batch.getElementsByTagName("option")[1].selected = true;
branch.disabled = false;
batch.disabled = false;
}
});

ghManifestLink = 'https://www.vishal-lokare.co/AutoJoomer/manifest.json'
$.getJSON(ghManifestLink, function (links) {
Expand All @@ -27,12 +37,6 @@ window.onload = function () {
}
});

document.getElementById("fpage").addEventListener("click", function () {
chrome.tabs.create({
url: chrome.runtime.getURL("full_page.html")
});
});

document.getElementById("aboutus").addEventListener("click", function () {
chrome.tabs.create({
url: chrome.runtime.getURL("contributors.html")
Expand All @@ -50,29 +54,45 @@ function saveValues() {
document.getElementById("button").disabled = true;
var uname = username.value;
var pass = password.value;
var uyear = document.getElementById("year").value;
var ubatch = document.getElementById("batch").value;

var bran = branch.value;
if (document.getElementById("confirmation").checked)
conf = 1;
else
conf = 0;
window.localStorage.setItem("AutoJoomerUsername", JSON.stringify(uname));
window.localStorage.setItem("AutoJoomerPassword", JSON.stringify(pass));
window.localStorage.setItem("AutoJoomerYear", JSON.stringify(uyear));
window.localStorage.setItem("AutoJoomerBranch", JSON.stringify(bran));
window.localStorage.setItem("AutoJoomerBatch", JSON.stringify(ubatch));
window.localStorage.setItem("AutoJoomerConfirmation", JSON.stringify(conf));
}

function populator() {
username = document.getElementById("username");
password = document.getElementById("password");
year = document.getElementById("year");
branch = document.getElementById("branch");
batch = document.getElementById("batch");
confirmation = document.getElementById("confirmation");
//setting the values
if (JSON.parse(window.localStorage.getItem("AutoJoomerUsername")) != null)
username.value = JSON.parse(window.localStorage.getItem("AutoJoomerUsername"));
if (JSON.parse(window.localStorage.getItem("AutoJoomerPassword")) != null)
password.value = JSON.parse(window.localStorage.getItem("AutoJoomerPassword"));
if (JSON.parse(window.localStorage.getItem("AutoJoomerYear")) != null)
year.value = JSON.parse(window.localStorage.getItem("AutoJoomerYear"));
if (year.value == "2019") {
branch.disabled = true;
batch.disabled = true;
}
if (JSON.parse(window.localStorage.getItem("AutoJoomerBranch")) != null)
branch.value = JSON.parse(window.localStorage.getItem("AutoJoomerBranch"));
if (JSON.parse(window.localStorage.getItem("AutoJoomerBatch")) != null)
batch.value = JSON.parse(window.localStorage.getItem("AutoJoomerBatch"));

if (JSON.parse(window.localStorage.getItem("AutoJoomerConfirmation")) == 1)
confirmation.checked = true;
if (JSON.parse(window.localStorage.getItem("AutoJoomerConfirmation")) == 0)
Expand Down
37 changes: 27 additions & 10 deletions script.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
var username = JSON.parse(window.localStorage.getItem("AutoJoomerUsername"));
var password = JSON.parse(window.localStorage.getItem("AutoJoomerPassword"));
var year = JSON.parse(window.localStorage.getItem("AutoJoomerYear"));
var branch = JSON.parse(window.localStorage.getItem("AutoJoomerBranch"));
var batch = JSON.parse(window.localStorage.getItem("AutoJoomerBatch"));
var confirmation = JSON.parse(window.localStorage.getItem("AutoJoomerConfirmation"));

if ((branch == null) || (branch == "null") || (username == null) || (password == null) || (username == "null") || (password == "null") || (username == "") || (password == "") || (confirmation == null)) {
alert("Some values have not been set. Navigate to the extensions panel in your browser, choose \"AutoJoomer\", save your values and restart your browser for changes to take effect.");
if (year == "" || branch == "" || batch == "" || username == "" || password == "" || confirmation == null) {
if (year == "2019")
runningscript();
else
alert("Some values have not been set. Navigate to the extensions panel in your browser, choose \"AutoJoomer\", save your values and restart your browser for changes to take effect.");
} else {
runningscript();
}
Expand Down Expand Up @@ -65,6 +70,8 @@ function runningscript() {
br = "CSE";
else
br = "ECE";
var dbReference = year + br + batch;
// console.log(dbReference);

const firebaseConfig = {
apiKey: "AIzaSyDbgLGtFvaeR_4n_9UPuvkhcXjsLc0-ERk",
Expand All @@ -78,27 +85,37 @@ function runningscript() {
};

firebase.initializeApp(firebaseConfig);
var db = firebase.database().ref().child('links').child(br).child(day)
var db = firebase.database().ref().child('links').child(dbReference).child(day);
db.on('value', function (links) {
console.log("AutoJoomer started");
if (links.val() == null || links.val().length == 1) {
window.alert("No classes found for today.");
return;
}
for (let i = 0; i < timeouts.length; i++)
clearTimeout(timeouts[i]);
var thatDay = links.toJSON();
//counts the number of lectures on that day
if (thatDay != null) {
//counts the number of lectures on that day
var nooflec = Object.keys(thatDay).length;
for (let i = 1; i < nooflec; i++) {
for (let i = 1, j = 0; i < nooflec; i++, j++) {
let now = new Date();
var thatClass = thatDay[i];

thatClassName[i] = thatClass['class_name'];
thatClassLink[i] = thatClass['class_link'];
//to check if the class name, link, time is/are empty
if (thatClassName[i] == '' || thatClassLink[i] == '' || thatClass['class_time'] == '') continue;
if (!thatClassName[i] || !thatClassLink[i] || !thatClass['class_time']) continue;

//parseint to convert string to integer
h[i] = String(thatClass['class_time'][0]) + String(thatClass['class_time'][1]);
m[i] = String(thatClass['class_time'][2]) + String(thatClass['class_time'][3]);
//to check if the class name or link is empty
if ((thatClassName[i] == '') || (thatClassLink[i] == '')) continue;
h[i] = thatClass['class_time'].substring(0, 2);
m[i] = thatClass['class_time'].substring(2, 4);
console.log(thatClassName[i] + " " + thatClassLink[i].substring(thatClassLink[i].length - 22, thatClassLink[i].length - 18) + " " + h[i] + " " + m[i]);

millisOfThatClass[i] = new Date(now.getFullYear(), now.getMonth(), now.getDate(), parseInt(h[i]), parseInt(m[i]), 0, 0) - now;
if (millisOfThatClass[i] > 0) {
timeouts[i] = setTimeout(function () {
timeouts[j] = setTimeout(function () {
if (confirmation == 1) {
if (window.confirm('Now the class is ' + thatClassName[i] + ' at ' + h[i] + ":" + m[i]))
window.open(thatClassLink[i], "_blank");
Expand Down
5 changes: 3 additions & 2 deletions version_updates.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"2.1.1": "Added support for extra classes and all other club meets/events",
"2.1.2": "Added an About Us page",
"2.2.0": "Automatically updates in realtime on changes to database",
"2.2.1": "Automatic values fill in popup"
}
"2.2.1": "Automatic values fill in popup",
"2.3": "4th Semester classes added for 19, 20, 21 batch"
}

0 comments on commit 6a34fc6

Please sign in to comment.