fixed description bug
This commit is contained in:
@@ -36,7 +36,10 @@ chrome.runtime.onMessage.addListener(function(request, sender, response) {
|
||||
const method = request.method ? request.method.toUpperCase() : "GET";
|
||||
xhr.open(method, request.url, true);
|
||||
console.log(request);
|
||||
xhr.onload = () => response(xhr.responseText);
|
||||
xhr.onload = () => {
|
||||
console.log(xhr.responseUrl);
|
||||
response(xhr.responseText);
|
||||
}
|
||||
xhr.onerror = () => response(xhr.statusText);
|
||||
if (method == "POST") {
|
||||
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
||||
@@ -253,9 +256,9 @@ function updateTabs() {
|
||||
});
|
||||
}
|
||||
|
||||
const UPDATE_INTERVAL = 1000 * 60 * 16; // 16 mins
|
||||
const UPDATE_INTERVAL = 1000 * 60 * 16;
|
||||
setInterval(updateStatus, UPDATE_INTERVAL);
|
||||
|
||||
// updateStatus();
|
||||
function updateStatus(sendResponse) {
|
||||
chrome.storage.sync.get('savedCourses', function(data) {
|
||||
var courses = data.savedCourses;
|
||||
@@ -264,26 +267,28 @@ function updateStatus(sendResponse) {
|
||||
try {
|
||||
let c = courses[i];
|
||||
let oldstatus = c.status;
|
||||
let oldlink = c.registerlink;
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("GET", c.link, false);
|
||||
xhr.send();
|
||||
let result = xhr.responseText;
|
||||
let dummy = document.createElement('html');
|
||||
dummy.innerHTML = result;
|
||||
let newstatus = dummy.querySelector('[data-th="Status"]').textContent;
|
||||
let registerlink = dummy.querySelector('td[data-th="Add"] a');
|
||||
if (registerlink) {
|
||||
registerlink = registerlink.getAttribute('href');
|
||||
}
|
||||
var haschanged = (newstatus == oldstatus && registerlink == oldlink);
|
||||
if (!haschanged) {
|
||||
console.log(c.unique + 'updated from ' + oldstatus + " to " + newstatus + " and " + oldlink + " to " + registerlink);
|
||||
}
|
||||
nochange &= haschanged;
|
||||
c.registerlink = registerlink;
|
||||
c.status = newstatus;
|
||||
let oldlink = c.link;
|
||||
$.ajax({url: oldlink, success: function(result){
|
||||
if(result){
|
||||
console.log(result);
|
||||
var object = $('<div/>').html(result).contents();
|
||||
let newstatus = object.find('[data-th="Status"]').text();
|
||||
let registerlink = object.find('td[data-th="Add"] a');
|
||||
if (registerlink) {
|
||||
registerlink = registerlink.attr('href');
|
||||
}
|
||||
var haschanged = (newstatus == oldstatus && registerlink == oldlink);
|
||||
if (!haschanged) {
|
||||
console.log(c.unique + ' updated from ' + oldstatus + " to " + newstatus + " and " + oldlink + " to " + registerlink);
|
||||
}
|
||||
nochange &= haschanged;
|
||||
c.registerlink = registerlink;
|
||||
c.status = newstatus;
|
||||
}}});
|
||||
|
||||
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
console.log('Not logged into UT Coursebook. Could not update class statuses.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -716,14 +716,9 @@ function getDescription() {
|
||||
// console.log(window.location.href);
|
||||
// console.log(profurl);
|
||||
console.log('hello');
|
||||
chrome.runtime.sendMessage({
|
||||
method: "GET",
|
||||
action: "xhttp",
|
||||
url: profurl,
|
||||
data: ""
|
||||
}, function (response) {
|
||||
if (response) {
|
||||
// console.log(response);
|
||||
$.ajax({url: profurl, success: function(response){
|
||||
if (response) {
|
||||
console.log(profurl);
|
||||
var output = "";
|
||||
var object = $('<div/>').html(response).contents();
|
||||
object.find('#details > p').each(function () {
|
||||
@@ -740,6 +735,7 @@ function getDescription() {
|
||||
output += sentence;
|
||||
});
|
||||
description = output;
|
||||
console.log(response);
|
||||
if (!description) {
|
||||
description = "<p style='color:red;font-style:bold'>You have been logged out. Please refresh the page and log back in using your UT EID and password.</p>"
|
||||
}
|
||||
@@ -771,7 +767,7 @@ function getDescription() {
|
||||
rmpLink = "http://www.ratemyprofessors.com/campusRatings.jsp?sid=1255";
|
||||
eCISLink = "http://utdirect.utexas.edu/ctl/ecis/results/index.WBX?";
|
||||
}
|
||||
});
|
||||
}});
|
||||
}
|
||||
/* Load the database*/
|
||||
function loadDataBase() {
|
||||
|
||||
Reference in New Issue
Block a user