summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Xu (Hello71) <alex_y_xu@yahoo.ca>2018-10-04 18:57:41 -0400
committerAlex Xu (Hello71) <alex_y_xu@yahoo.ca>2018-10-04 18:57:41 -0400
commitd908f4c81e71ef7db4d086afcf72af84f34b9cdb (patch)
tree29577fed160da298ff41f4b1042158eadc2b67d4
parent3fe25fa48f199538ddbdfc1c7ac8e966075b27f9 (diff)
downloadyorku-web-helper-d908f4c81e71ef7db4d086afcf72af84f34b9cdb.tar.xz
yorku-web-helper-d908f4c81e71ef7db4d086afcf72af84f34b9cdb.zip
-rw-r--r--crsq.js14
-rw-r--r--crsq1.js17
-rw-r--r--manifest.json5
3 files changed, 18 insertions, 18 deletions
diff --git a/crsq.js b/crsq.js
index 289a739..1b1e186 100644
--- a/crsq.js
+++ b/crsq.js
@@ -34,7 +34,7 @@ xhr.onreadystatechange = function () {
// emulate document.write script
// use if statement instead of conditional operator to pacify AMO auto reviewer
var s = xhr.responseXML.body.querySelector("script").parentNode;
- if (/(?:mayaauth|mayaanyoneauth)/.test(document.cookie)) {
+ if (/(?:mayaauth|mayaanyoneauth)=/.test(document.cookie)) {
s.innerHTML = '<TABLE width="200" cellpadding="5" cellspacing="0" border="0"><TR><TD><P><a href="https://passportyork.yorku.ca/ppylogin/ppylogout"><IMG src="https://w2prod.sis.yorku.ca/WebObjects/YorkUimages/logout.gif" width="154" height="45" border="0"></a><BR><SPAN class="smallbodytext"><A href="http://www.yorku.ca/yorkweb/currentstudents/ppystudents.html">All About Passport York</A></SPAN></P></TD></TR></TABLE>';
} else {
s.innerHTML = '<TABLE border="0"><TR><TD><img src="https://w2prod.sis.yorku.ca/WebObjects/YorkUimages/passportyorksmall2.gif" width="73" height="42"></TD><TD><B>New Student?</B><BR><a href="http://www.yorku.ca/yorkweb/currentstudents/ppystudents.html">All about Passport&nbsp;York</a></TD></TR></TABLE>';
@@ -43,7 +43,7 @@ xhr.onreadystatechange = function () {
var avs = xhr
.responseXML
.evaluate(
- '//a[contains(text(), "Please click here to see availability.")]',
+ '//a[contains(text(), "Please click here to see availability")]',
xhr.responseXML.body
);
var avsa = [];
@@ -51,12 +51,10 @@ xhr.onreadystatechange = function () {
while ((av = avs.iterateNext()))
avsa.push(av);
avsa.forEach(function (av) {
- var newHref = av.href
- .replace(/(https?:\/\/[^.\/]*\.sis\.yorku\.ca\/Apps\/WebObjects\/cdm\.woa\/wa\/loginppy\?url=).*/,
- "$1" + encodeURIComponent(location.pathname + location.search + location.hash)
- );
- if (newHref != av.href)
- av.href = newHref;
+ var newSearch = av.search.replace(/url=[^&]*/,
+ "url=" + encodeURIComponent(location.pathname + location.search + location.hash));
+ if (newSearch != av.search)
+ av.search = newSearch;
});
document.body.replaceChild(xhr.responseXML.body.children[0], document.body.children[0]);
diff --git a/crsq1.js b/crsq1.js
index 0f4e8dd..c392c14 100644
--- a/crsq1.js
+++ b/crsq1.js
@@ -1,6 +1,10 @@
(function () {
"use strict";
+const BAD_LINK_RE = /\/Apps\/WebObjects\/cdm\.woa\/[0-9]+\/wo\/[A-Za-z0-9]+\/[0-9.]+/;
+const COURSE_ID_RE = /^([A-Z]{2})[\/ ]+([A-Z]{2,4})\s+([0-9]{4})\s+([0-9.]+)$/;
+const LINK_YEAR_RE = /^[A-Za-z\/]+\s+([0-9]+)/
+
let scheduleLinks = document.evaluate('//a[contains(text(), " Course Schedule")]', document.body);
if (!scheduleLinks)
return;
@@ -10,26 +14,21 @@ while ((scheduleLink = scheduleLinks.iterateNext())) {
scheduleLinksa.push(scheduleLink);
}
-const BAD_LINK_RE = /\/Apps\/WebObjects\/cdm\.woa\/[0-9]+\/wo\/[A-Za-z0-9]+\/[0-9.]+/;
-const COURSE_ID_RE = /^([A-Z]{2})[\/ ]+([A-Z]{2,4})\s+([0-9]{4})\s+([0-9.]+)$/;
-const LINK_YEAR_RE = /^[A-Za-z\/]+\s+([0-9]+)/
-
scheduleLinksa.forEach(function (scheduleLink) {
if (BAD_LINK_RE.test(scheduleLink.pathname)) {
let courseId = COURSE_ID_RE.exec(scheduleLink.parentNode.parentNode.children[0].textContent);
if (!courseId)
return;
- let year, sess;
+ let sess;
if (scheduleLink.textContent.startsWith("Fall/Winter")) {
sess = "FW";
- year = LINK_YEAR_RE.exec(scheduleLink.textContent)[1];
} else if (scheduleLink.href.startsWith("Summer")) {
sess = "SU";
- year = LINK_YEAR_RE.exec(scheduleLink.textContent)[1];
}
- if (year && sess) {
+ let rematch = LINK_YEAR_RE.exec(scheduleLink.textContent);
+ if (rematch && sess) {
scheduleLink.pathname = "/Apps/WebObjects/cdm.woa/wa/crsq";
- scheduleLink.search = `fa=${courseId[1]}&sj=${courseId[2]}&cn=${courseId[3]}&cr=${courseId[4]}&ay=${year}&ss=${sess}`;
+ scheduleLink.search = `fa=${courseId[1]}&sj=${courseId[2]}&cn=${courseId[3]}&cr=${courseId[4]}&ay=${rematch[1]}&ss=${sess}`;
}
}
});
diff --git a/manifest.json b/manifest.json
index 936cf7e..b1af075 100644
--- a/manifest.json
+++ b/manifest.json
@@ -5,7 +5,10 @@
"description": "Unofficial York University website helper extension.",
"content_scripts": [
{
- "matches": ["*://*.sis.yorku.ca/Apps/WebObjects/cdm.woa/wa/crsq?*"],
+ "matches": [
+ "*://*.sis.yorku.ca/Apps/WebObjects/cdm.woa/wa/crsq?*",
+ "*://*.sis.yorku.ca/Apps/WebObjects/cdm.woa/wa/CRSQuery?*"
+ ],
"run_at": "document_end",
"js": ["crsq.js"]
},