summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Xu (Hello71) <alex_y_xu@yahoo.ca>2018-09-18 16:08:48 -0400
committerAlex Xu (Hello71) <alex_y_xu@yahoo.ca>2018-09-18 16:08:48 -0400
commit0d046223e2b2478473bef39e053d3021fbe169b0 (patch)
tree1c1cec190c8c2f78a2982408ca80e76701e2bc8a
downloadyorku-web-helper-0d046223e2b2478473bef39e053d3021fbe169b0.tar.xz
yorku-web-helper-0d046223e2b2478473bef39e053d3021fbe169b0.zip
Initial commit
-rw-r--r--.gitmodules3
-rw-r--r--action_popup/action_popup.html19
-rw-r--r--action_popup/action_popup.js5
-rw-r--r--crsq.js66
-rw-r--r--manifest.json18
m---------yorku-course-query0
6 files changed, 111 insertions, 0 deletions
diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 0000000..c4f5b49
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,3 @@
+[submodule "yorku-course-query"]
+ path = yorku-course-query
+ url = https://git.alxu.ca/yorku-course-query.git
diff --git a/action_popup/action_popup.html b/action_popup/action_popup.html
new file mode 100644
index 0000000..720b4ec
--- /dev/null
+++ b/action_popup/action_popup.html
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <link rel="stylesheet" href="choose_beast.css"/>
+ </head>
+ <body>
+ <header class="panel-section panel-section-header">
+ <!--<div class="icon-section-header">[insert image here]</div>-->
+ <div class="text-section-header">YorkU Web Helper</div>
+ </header>
+ <div class="panel-section panel-section-list">
+ <div id="course-query-link" class="panel-list-item">
+ <div class="text">Course Query</div>
+ </div>
+ </div>
+ <script src="action_popup.js"></script>
+ </body>
+</html>
diff --git a/action_popup/action_popup.js b/action_popup/action_popup.js
new file mode 100644
index 0000000..914041a
--- /dev/null
+++ b/action_popup/action_popup.js
@@ -0,0 +1,5 @@
+document.getElementById("course-query-link").addEventListener("click", function () {
+ chrome.tabs.create({
+ "url": "/yorku-course-query/index.html"
+ });
+});
diff --git a/crsq.js b/crsq.js
new file mode 100644
index 0000000..3fb7ea5
--- /dev/null
+++ b/crsq.js
@@ -0,0 +1,66 @@
+(function () {
+"use strict";
+
+var scheduleLink = document.evaluate('//a[contains(text(), " Schedule")]', document.body).iterateNext();
+
+if (!scheduleLink)
+ return;
+
+if (document.getElementById("loading-notice"))
+ return;
+
+var loadingNotice = document.createElement("span");
+loadingNotice.id = "loading-notice";
+loadingNotice.innerHTML = " (loading, please wait)";
+scheduleLink.parentNode.appendChild(loadingNotice);
+
+var xhr;
+// show the xhr in dev tools
+try {
+ xhr = XPCNativeWrapper(new window.wrappedJSObject.XMLHttpRequest());
+} catch (e) {
+ xhr = new XMLHttpRequest();
+}
+xhr.responseType = 'document';
+xhr.open('GET', scheduleLink.href, true);
+xhr.onreadystatechange = function () {
+ if (xhr.readyState !== xhr.DONE)
+ return;
+
+ if (xhr.status === 200 &&
+ xhr.responseXML &&
+ xhr.responseXML.title === "York University Courses Website - Courses Schedule"
+ ) {
+ // emulate document.write script
+ xhr.responseXML.body.querySelector("script").parentNode.innerHTML =
+ /(?:mayaauth|mayaanyoneauth)/.test(document.cookie) ?
+ '<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>' :
+ '<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>';
+
+ var avs = xhr
+ .responseXML
+ .evaluate(
+ '//a[contains(text(), "Please click here to see availability.")]',
+ xhr.responseXML.body
+ );
+ var avsa = [];
+ var av;
+ 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;
+ });
+
+ document.body.replaceChild(xhr.responseXML.body.children[0], document.body.children[0]);
+ } else {
+ loadingNotice.innerHTML = " (loading failed)";
+ }
+};
+xhr.send(null);
+
+}());
diff --git a/manifest.json b/manifest.json
new file mode 100644
index 0000000..aa3b565
--- /dev/null
+++ b/manifest.json
@@ -0,0 +1,18 @@
+{
+ "manifest_version": 2,
+ "name": "YorkU Web Helper",
+ "version": "1.0",
+ "description": "Unofficial York University website helper extension.",
+ "content_scripts": [
+ {
+ "matches": ["*://*.sis.yorku.ca/Apps/WebObjects/cdm.woa/wa/crsq?*"],
+ "run_at": "document_end",
+ "js": ["crsq.js"]
+ }
+ ],
+ "browser_action": {
+ "browser_style": true,
+ "default_title": "YorkU Web Helper",
+ "default_popup": "action_popup/action_popup.html"
+ }
+}
diff --git a/yorku-course-query b/yorku-course-query
new file mode 160000
+Subproject 6d1016e2dfb3d0b10d8e7203dd217382821ab42