From b33478fce44780949dfa420236bafb16b6754138 Mon Sep 17 00:00:00 2001 From: Vishal Date: Fri, 28 Jan 2022 10:10:20 +0530 Subject: [PATCH] added 2021 temporarily --- logger.js | 24 +++++++++++------------- manifest.json | 5 +++-- popup.html | 17 ++++++++++++++--- popup.js | 14 ++++++++++++++ script.js | 21 ++++++++++++++++----- 5 files changed, 58 insertions(+), 23 deletions(-) diff --git a/logger.js b/logger.js index d70a422..8e88555 100644 --- a/logger.js +++ b/logger.js @@ -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); } }) \ No newline at end of file diff --git a/manifest.json b/manifest.json index ca5ab4b..ec9cc53 100644 --- a/manifest.json +++ b/manifest.json @@ -23,8 +23,9 @@ "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", diff --git a/popup.html b/popup.html index ad5989f..8b77bd1 100644 --- a/popup.html +++ b/popup.html @@ -42,6 +42,7 @@ color: white; background: none; border: 0; + width: fit-content; } select:focus { @@ -55,7 +56,7 @@ label { color: white; - font-size: 110%; + font-size: 100%; } .switch { @@ -130,11 +131,21 @@

+ +

@@ -151,4 +162,4 @@ - + \ No newline at end of file diff --git a/popup.js b/popup.js index fbfbf9c..b29f7b9 100644 --- a/popup.js +++ b/popup.js @@ -6,7 +6,9 @@ var confirmation; window.onload = function () { username = document.getElementById("username"); password = document.getElementById("password"); + year = document.getElementById("year"); branch = document.getElementById("branch"); + batch = document.getElementById("batch"); confirmation = document.getElementById("confirmation"); populator(); document.getElementById("button").addEventListener("click", saveValues); @@ -50,6 +52,9 @@ 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; @@ -57,22 +62,31 @@ function saveValues() { 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 (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) diff --git a/script.js b/script.js index 55f2147..978460a 100644 --- a/script.js +++ b/script.js @@ -1,9 +1,12 @@ 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)) { +// if ((year = "null") || (batch == "null") || (branch == "null") || (username == null) || (password == null) || (username == "null") || (password == "null") || (username == "") || (password == "") || (confirmation == null)) { +if (year == "null" || branch == "null" || batch == "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."); } else { runningscript(); @@ -65,6 +68,8 @@ function runningscript() { br = "CSE"; else br = "ECE"; + var dbReference = year + br + batch; + console.log(dbReference); const firebaseConfig = { apiKey: "AIzaSyDbgLGtFvaeR_4n_9UPuvkhcXjsLc0-ERk", @@ -78,22 +83,28 @@ 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); db.on('value', function (links) { console.log("AutoJoomer started"); + if (links.val() == null) { + window.alert("No classes found for today."); + return; + } for (let i = 0; i < timeouts.length; i++) clearTimeout(timeouts[i]); - var thatDay = links.toJSON(); + var thatDay = links.toJSON()[day]; + console.log(thatDay); //counts the number of lectures on that day if (thatDay != null) { var nooflec = Object.keys(thatDay).length; for (let i = 1; i < nooflec; i++) { var thatClass = thatDay[i]; + console.log(thatClass); thatClassName[i] = thatClass['class_name']; thatClassLink[i] = thatClass['class_link']; //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]); + h[i] = thatClass['class_time'].substring(0, 2); + m[i] = thatClass['class_time'].substring(2, 4); //to check if the class name or link is empty if ((thatClassName[i] == '') || (thatClassLink[i] == '')) continue; millisOfThatClass[i] = new Date(now.getFullYear(), now.getMonth(), now.getDate(), parseInt(h[i]), parseInt(m[i]), 0, 0) - now;