Last active
September 26, 2016 17:01
-
-
Save karlding/4b3c8e376cd88d5bbd7a to your computer and use it in GitHub Desktop.
Prevents uWaterloo's JobMine system from logging you out automatically
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name JobMine4Days | |
// @namespace https://github.com/karlding | |
// @version 1.1 | |
// @description Prevents uWaterloo's JobMine system from logging you out automatically | |
// @author Karl Ding | |
// @include https://jobmine.ccol.uwaterloo.ca/psp/SS* | |
// @include https://jobmine.ccol.uwaterloo.ca/psc/SS* | |
// @include https://jobmine.ccol.uwaterloo.ca/psp/ES* | |
// @include https://jobmine.ccol.uwaterloo.ca/psc/ES* | |
// @grant none | |
// ==/UserScript== | |
window.addEventListener('load', function() { | |
var poll = function() { | |
var request = new XMLHttpRequest(); | |
var url = '//jobmine.ccol.uwaterloo.ca/psp/SS/EMPLOYEE/WORK/?cmd=resettimeout'; | |
request.open('GET', url, true); | |
request.onload = function() { | |
if (request.status >= 200 && request.status < 400) { | |
console.log(request.responseText); | |
} else { | |
console.warn("Error: HTTP Status Code " + request.status); | |
} | |
}; | |
request.onerror = function(e) { | |
console.warn("Error: Retrying request"); | |
setTimeout(function() { | |
poll(); | |
}, 60000); // 60000ms = 1min | |
}; | |
request.send(); | |
}; | |
// warningTimeoutMilliseconds / 2 = 1080000ms / 2 = 9min | |
setInterval(poll, warningTimeoutMilliseconds / 2); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment