Skip to content

Instantly share code, notes, and snippets.

@sizzlemctwizzle
Created September 26, 2013 02:19
Show Gist options
  • Select an option

  • Save sizzlemctwizzle/6708974 to your computer and use it in GitHub Desktop.

Select an option

Save sizzlemctwizzle/6708974 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Remember SignOn
// @namespace sizzlemctwizzle
// @description Sign on once and forever
// @include https://sso.queensu.ca/amserver/UI/Login
// @grant none
// @version 1
// ==/UserScript==
// Uncomment this if you fuck up.
// Reload the page and then comment it out again.
// Then reload the page again and sign in.
//localStorage.removeItem('signon');
HTMLFormElement.prototype.oldSubmit = HTMLFormElement.prototype.submit;
HTMLFormElement.prototype.submit = function() {
var inputs = this.getElementsByTagName('input');
var vals = {'formName': this.name};
for (var i = 0, len = inputs.length; i < len; ++i) {
vals[inputs[i].name] = inputs[i].value;
}
localStorage.setItem('signon', JSON.stringify(vals));
this.oldSubmit();
};
var str = localStorage.getItem('signon');
if (str) {
var vals = JSON.parse(str);
var formName = vals['formName'];
var form = document.forms[formName];
for (var i in vals) {
if (i == 'formName') continue;
form[i].value = vals[i];
}
form.oldSubmit();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment