-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathscript.user.js
33 lines (31 loc) · 1.25 KB
/
script.user.js
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
// ==UserScript==
// @name Refuse2Logout
// @namespace http://userscripts.org/users/vtsatskin
// @include http://learn.uwaterloo.ca/*
// @include https://learn.uwaterloo.ca/*
// @description Prevents uWaterloo's Desire2Learn from logging you out automatically
// @version 0.0.2
// ==/UserScript==
window.addEventListener('load', function () {
var POLL_INTERVAL = 10 * 6E4 // 10 minutes in ms
, POLL_URL = "/d2l/lp/auth/session/extend"
, tapItLikeItsHot = function () {
try {
var oReq = new XMLHttpRequest();
oReq.open("GET", POLL_URL, true);
oReq.onreadystatechange = function (oEvent) {
if (oReq.readyState === 4) {
if (oReq.status === 200) {
console && console.log && console.log("Successfully polled D2L!");
} else {
console && console.error && console.error("Polling error: ", oReq.statusText);
}
}
};
oReq.send(null);
} catch (err) {
console && console.error && console.error(err);
}
};
setInterval(tapItLikeItsHot, POLL_INTERVAL);
});