summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Xu (Hello71) <alex_y_xu@yahoo.ca>2018-09-19 15:12:18 -0400
committerAlex Xu (Hello71) <alex_y_xu@yahoo.ca>2018-09-19 15:12:18 -0400
commit3fe25fa48f199538ddbdfc1c7ac8e966075b27f9 (patch)
tree594088b90615cf760d334e97da6151c48e20fad6
parent7ede81e82f608af89c9c238acf598bf9f47b765a (diff)
downloadyorku-web-helper-3fe25fa48f199538ddbdfc1c7ac8e966075b27f9.tar.xz
yorku-web-helper-3fe25fa48f199538ddbdfc1c7ac8e966075b27f9.zip
add crsq1
-rw-r--r--crsq1.js36
-rw-r--r--manifest.json5
2 files changed, 41 insertions, 0 deletions
diff --git a/crsq1.js b/crsq1.js
new file mode 100644
index 0000000..0f4e8dd
--- /dev/null
+++ b/crsq1.js
@@ -0,0 +1,36 @@
+(function () {
+"use strict";
+
+let scheduleLinks = document.evaluate('//a[contains(text(), " Course Schedule")]', document.body);
+if (!scheduleLinks)
+ return;
+
+let scheduleLink, scheduleLinksa = [];
+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;
+ 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) {
+ 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}`;
+ }
+ }
+});
+}());
diff --git a/manifest.json b/manifest.json
index aa3b565..936cf7e 100644
--- a/manifest.json
+++ b/manifest.json
@@ -8,6 +8,11 @@
"matches": ["*://*.sis.yorku.ca/Apps/WebObjects/cdm.woa/wa/crsq?*"],
"run_at": "document_end",
"js": ["crsq.js"]
+ },
+ {
+ "matches": ["*://*.sis.yorku.ca/Apps/WebObjects/cdm.woa/wa/crsq1?*"],
+ "run_at": "document_end",
+ "js": ["crsq1.js"]
}
],
"browser_action": {