blob: 1b1e186974a1007a580840710dbae2ac0a56e910 (
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
67
|
(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
// 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)) {
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 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 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]);
} else {
loadingNotice.innerHTML = " (loading failed)";
}
};
xhr.send(null);
}());
|