Skip to content

Instantly share code, notes, and snippets.

@dreamalligator
Created July 30, 2013 21:16
Show Gist options
  • Save dreamalligator/6117046 to your computer and use it in GitHub Desktop.
Save dreamalligator/6117046 to your computer and use it in GitHub Desktop.
SFSU user script to re-log yourself back in.
// ==UserScript==
// @name SFSU
// @namespace namethisspace
// @description Personal user script for SFSU
// @include https://idp.sfsu.edu/idp/Authn/UserPassword
// @require http://code.jquery.com/jquery-latest.min.js
// @version 1
// ==/UserScript==
// This user script auto-logs you into SFSU. I suggest that you do not save your password OR username in this. Instead, make a quick script to save your username and password in Greasemonkey's persistent data. I made this because I was continually annoyed at how many times I have to log back in. Be safe with your information.
// Example of such a script:
// GM_setValue("SFSUname","YOURLOGIN");
// GM_setValue("SFSUpassword","YOURPASS");
//====================
var pagename=location.pathname;
var pageGateway='/idp/Authn/UserPassword';
var pages=[pageGateway];
//====================
// Flags
//====================
flagAutoLogin=true;
//====================
// Functions
//====================
window.addEventListener("load",sfsuMain,false);
function sfsuMain(){
if(myPage()){
if(pagename==pageGateway){
fillLogin();
}
}
return;}
//====================
// Check if amongst the pages I want to operate on
//====================
function myPage(){
if (pages.indexOf(pagename)>=0){//returns -1 if not in array, otherwise returns index
return true;
}
else
alert(pagename+" has no extra functions running");
return false;}
//====================
// https://idp.sfsu.edu/idp/Authn/UserPassword
//====================
function fillLogin(){
//change autocomplete to on? not necessary.
//$('form').attr("autocomplete","on");
var username=GM_getValue("SFSUname","YOURLOGIN");
$('input[name="j_username"]').val(username);
var password=GM_getValue("SFSUpassword","YOURPASS");
$('input[name="j_password"]').val(password);
//press login button?
if(flagAutoLogin){
$('input[value="Login"]').click();
}
return;}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment