blob: 3fb7ea5c5fa99e92a217fc049116b8f44d6b01a7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
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 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);
}());
|