-
Notifications
You must be signed in to change notification settings - Fork 10
Showing an error message on invalid URLs #16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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": | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I could not find error code in the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks fine. However, I don't see the need for both an |
||
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"; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,9 @@ | ||
function activate() { | ||
|
||
if (!(document.location.href === "https://aims.iith.ac.in/aims/courseReg/studentRegForm/44")) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This URL may very well change, so use a constant variable here. |
||
return false | ||
} | ||
|
||
var timeTabIcons = document.getElementsByClassName("time_tab_icon"); | ||
for (var i = 0 ; i < timeTabIcons.length ; i++) | ||
{ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove "probably". Add "please" before Goto.