diff options
author | Alex Xu (Hello71) <alex_y_xu@yahoo.ca> | 2018-10-04 18:57:41 -0400 |
---|---|---|
committer | Alex Xu (Hello71) <alex_y_xu@yahoo.ca> | 2018-10-04 18:57:41 -0400 |
commit | d908f4c81e71ef7db4d086afcf72af84f34b9cdb (patch) | |
tree | 29577fed160da298ff41f4b1042158eadc2b67d4 /crsq1.js | |
parent | 3fe25fa48f199538ddbdfc1c7ac8e966075b27f9 (diff) | |
download | yorku-web-helper-master.tar.xz yorku-web-helper-master.zip |
Diffstat (limited to 'crsq1.js')
-rw-r--r-- | crsq1.js | 17 |
1 files changed, 8 insertions, 9 deletions
@@ -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}`; } } }); |