Month: June 2009

AutoLogin GreaseMonkey Script

Here is a GreaseMonkey Script that changes the languages options on the PeopleSoft login page to users’ names.  When you click on the user’s name, it populates the username and password.  It is great for when you are testing Workflow or something like that.


// ==UserScript==
// @name           PSautologin
// @namespace      http://psst0101.wordpress.com
// @description    Automatic Login for PS
// @include        http://ps_server:*/psp/*/EMPLOYEE/ERP/?cmd=logout
// @include        http://ps_server:*/psp/*/?cmd=login*
// @include        http://ps_server:*/psp/HR90CNV/*/HRMS/?cmd=logout
// ==/UserScript==

// set up jQuery variable
var $;

// Add jQuery
var GM_JQ = document.createElement("script");
GM_JQ.src = "http://code.jquery.com/jquery-latest.min.js";
GM_JQ.type = "text/javascript";

document.body.appendChild(GM_JQ);

// Check if jQuery's loaded
var checker=setInterval(function(){
if(typeof ($ = unsafeWindow.jQuery) != "undefined") {
clearInterval(checker);
letsJQuery();
}
},100);

// All your GM code must be inside this function
function letsJQuery() {
var selectALanguage = $('.pslanguageframe .psloginlabel:contains("Select a Language")');
selectALanguage.text("Select A User:");
$('.pslanguageframe .pslogintext').toggleClass('skpremove');
$('.pslanguageframe .pslogintext').text("Hello");
$('.pslanguageframe .textnormal').remove();
$('.pslanguageframe .pslogintext:first').text("test");
addUser('PS', 'PS');
addUser('VP1', 'VP1');
$('.pslanguageframe .skpremove').remove();

$('table:first table:first > tbody > tr:eq(1) td').html('<a href="http://serverWithList/">Other Instances</a>');
}

function addUser(userName, password) {
var newLink = $('.pslanguageframe .skpremove:first').html("<a href='javascript:login'>" + userName + "</a>").toggleClass('skpremove').children('a');
newLink.attr('userName', userName);
newLink.attr('password', password);
newLink.click(loginwith);
}

function loginwith() {
userName = $(this).attr('userName');
password = $(this).attr('password');

$('#userid').val(userName);
$('#pwd').val(password);

// don't trigger URL for link
return false;
}