diff --git a/src/gpa/activateGPA.js b/src/gpa/activateGPA.js
index e5af4b4..a1f0a33 100644
--- a/src/gpa/activateGPA.js
+++ b/src/gpa/activateGPA.js
@@ -49,6 +49,11 @@ add_checkboxes = function(){
}
show_total_gpa = function(){
+
+ if (document.location.href !== "https://aims.iith.ac.in/aims/courseReg/myCrsHistoryPage") {
+ return null;
+ }
+
var courses = [];
$('#gpa_button').val('Calculating');
$('#gpa_bar').remove();
diff --git a/src/popup/popup.html b/src/popup/popup.html
index a815d92..74291ce 100644
--- a/src/popup/popup.html
+++ b/src/popup/popup.html
@@ -58,7 +58,11 @@
- You are not on the AIMS Page.
+ You are probably not on the appropriate AIMS page. Goto Course Registration for timetable and View my courses for GPA.
+ If you think this is a mistake, please reach us at lambda@iith.ac.in
+
GPA =
diff --git a/src/popup/popup.js b/src/popup/popup.js
index 291ef05..e5a5f79 100644
--- a/src/popup/popup.js
+++ b/src/popup/popup.js
@@ -1,10 +1,21 @@
var whichButton = 0 ; // 0 : no button has been clicked
+
+// Show the error message div
+function showError() {
+ document.getElementById("error-message").style.display = "block";
+ document.getElementsByClassName("button-container")[0].style.display = "none";
+ document.getElementById("loading-image").style.display = "none";
+}
+
+
chrome.runtime.onMessage.addListener((request, sender) => {
- if (request.action == "activateTimetable" && request.status == true)
- {
- onWindowLoad();
- }
+ if (request.action == "activateTimetable" && request.status == true) {
+ onWindowLoad();
+ }
+ else {
+ showError();
+ }
});
chrome.runtime.onMessage.addListener(function(request, sender) {
if (request.action == "getSource") {
@@ -38,19 +49,29 @@ function onWindowLoad() {
function showLoading() {
document.getElementById("loading-image").style.display = "block";
document.getElementsByClassName("button-container")[0].style.display="none";
+ document.getElementById("error-message").style.display = "none"; // adding to avoid any risks!
}
function removeLoading() {
document.getElementById("loading-image").style.display = "none";
document.getElementsByClassName("button-container")[0].style.display = "block";
+ document.getElementById("error-message").style.display = "none"; // adding to avoid any risks!
}
function injectTimetable() {
showLoading();
chrome.tabs.executeScript(null, {
file: "/src/timetable/activateTimetable.js"
- }, function() {
- if (chrome.runtime.lastError) console.log(chrome.runtime.lastError.message);
+ }, function () {
+ if (chrome.runtime.lastError) {
+ switch (chrome.runtime.lastError.message) {
+ case "Cannot access a chrome:// URL":
+ showError();
+ break;
+ default:
+ console.log(chrome.runtime.lastError.message);
+ }
+ }
});
}
@@ -68,6 +89,11 @@ function injectGPA() {
}
chrome.runtime.onMessage.addListener(function(request, sender){
if(request.action == "parsedGPA"){
+
+ if (!request.data) {
+ return showError();
+ }
+
removeLoading();
var gpa_value = request.data.gpa;
document.getElementsByClassName("gpa-container")[0].style.display = "flex";
diff --git a/src/timetable/activateTimetable.js b/src/timetable/activateTimetable.js
index f52ef3a..f259fda 100644
--- a/src/timetable/activateTimetable.js
+++ b/src/timetable/activateTimetable.js
@@ -1,4 +1,9 @@
function activate() {
+
+ if (!(document.location.href === "https://aims.iith.ac.in/aims/courseReg/studentRegForm/44")) {
+ return false
+ }
+
var timeTabIcons = document.getElementsByClassName("time_tab_icon");
for (var i = 0 ; i < timeTabIcons.length ; i++)
{