fixed description bug
This commit is contained in:
@@ -83,7 +83,9 @@ ul {
|
||||
i {
|
||||
padding: 4px 0px;
|
||||
}
|
||||
|
||||
#header {
|
||||
border-radius: 7px;
|
||||
}
|
||||
.settings {
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"manifest_version": 2,
|
||||
|
||||
"name": "UT Registration Plus",
|
||||
"version": "0.2.2.2",
|
||||
"version": "0.2.2.3",
|
||||
"options_page": "options.html",
|
||||
"description": "Improves the course registration process at the University of Texas at Austin!",
|
||||
"permissions": ["tabs",
|
||||
@@ -26,7 +26,7 @@
|
||||
"grades.db", "images/disticon.png"
|
||||
],
|
||||
"background": {
|
||||
"scripts": ["js/background.js", "js/moment.min.js", "js/jquery-3.3.1.min.js"],
|
||||
"scripts": ["js/jquery-3.3.1.min.js", "js/background.js", "js/moment.min.js"],
|
||||
"persistent": true
|
||||
},
|
||||
"browser_action": {
|
||||
|
||||
@@ -10,9 +10,9 @@
|
||||
<body style="position:relative;">
|
||||
<div class="card" id="header">
|
||||
<div id="buttons" style="padding: 5px 10px 5px 10px;display: flex;justify-content: space-between;">
|
||||
<button id="clear" class="matbut" style="font-size:15px; background:#4CAF50;margin: 10px;">Clear All</button>
|
||||
<button id="schedule" class="matbut" style="font-size:15px;background:#FF9800;margin: 10px;">Course List</button>
|
||||
<button id="calendar" class="matbut" style="font-size:15px; background: #FF0000; margin:10px;">My Schedule</button>
|
||||
<button id="clear" class="matbut" style="font-size:15px; background:#4CAF50;margin: 7px;">Clear All</button>
|
||||
<button id="schedule" class="matbut" style="font-size:15px;background:#FF9800;margin: 7px;">Course List</button>
|
||||
<button id="calendar" class="matbut" style="font-size:15px; background: #FF0000; margin:7px;">My Schedule</button>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
|
||||
Reference in New Issue
Block a user