diff --git a/css/popup.css b/css/popup.css index 9e875912..a3ec7b9b 100644 --- a/css/popup.css +++ b/css/popup.css @@ -83,7 +83,9 @@ ul { i { padding: 4px 0px; } - +#header { + border-radius: 7px; +} .settings { position: absolute; bottom: 0; diff --git a/js/background.js b/js/background.js index 8e82fa77..0953cab1 100644 --- a/js/background.js +++ b/js/background.js @@ -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 = $('
').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.'); } } diff --git a/js/content.js b/js/content.js index 319407c4..e3e71f30 100644 --- a/js/content.js +++ b/js/content.js @@ -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 = $('').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 = "You have been logged out. Please refresh the page and log back in using your UT EID and password.
" } @@ -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() { diff --git a/manifest.json b/manifest.json index 1803a40e..49843440 100644 --- a/manifest.json +++ b/manifest.json @@ -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": { diff --git a/popup.html b/popup.html index 240177c2..7fd5b801 100644 --- a/popup.html +++ b/popup.html @@ -10,9 +10,9 @@