Skip to content

Instantly share code, notes, and snippets.

@stefansundin
Last active January 1, 2016 23:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stefansundin/8214929 to your computer and use it in GitHub Desktop.
Save stefansundin/8214929 to your computer and use it in GitHub Desktop.
Old Greasemonkey/Tampermonkey script, but could be nice to have for people studying at Luleå University of Technology (LTU).
// ==UserScript==
// @name LTU Username
// @namespace https://gist.github.com/stefansundin/
// @homepage https://gist.github.com/stefansundin/8214929
// @downloadURL https://gist.github.com/stefansundin/8214929/raw/ltu_username.user.js
// @version 1.0
// @author Stefan Sundin
// @description Autofill username
// @include https://logon.pub.ltu.se/cgi-bin/logon.cgi
// @include https://fronter.com/ltu/
// @include https://fronter.com/ltu/index.phtml*
// @include https://weblogon.ltu.se/casfirst/login*
// ==/UserScript==
(function() {
var username = "sunset-8";
// Get url
var url = window.location.toString();
if (url.lastIndexOf("?") != -1) {
url = url.substring(0, url.lastIndexOf("?"));
}
if (url.lastIndexOf(";") != -1) {
// Stupid jsessionid
url = url.substring(0, url.lastIndexOf(";"));
}
// Autofill
switch (url) {
case "https://logon.pub.ltu.se/cgi-bin/logon.cgi":
// WLAN access
document.getElementsByName("user")[0].value = username;
document.getElementsByName("passwd")[0].focus();
break;
case "https://fronter.com/ltu/":
case "https://fronter.com/ltu/index.phtml":
// Fronter
document.getElementsByName("username")[0].value = username;
document.getElementsByName("password")[0].focus();
break;
case "https://weblogon.ltu.se/casfirst/login":
// CAS (portalen, kurswiki, etc.)
document.getElementById("username").value = username;
setTimeout(function(){
document.getElementById("password").focus();
}, 150);
break;
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment