GreaseMonkey Script — Go to next field UIBO website.
Author: JayBachatero
30
Oct
I got tired of having to press tab each time when I enter my SS number in the Unemployment Insurance Benefits Online website so I made this GreaseMonkey script. I'm not so good in JS but it gets the job done. I'm pretty sure it can be written better.
JavaScript:
-
-
// ==UserScript==
-
// @name Unemployment Insurance Benefits Online by JayBachatero
-
// @namespace http://www.jaybachatero.com
-
// @description Go to next field when entering ssn.
-
// @include https://ui.labor.state.ny.us/UBC/home.do
-
// @version 1.0
-
// ==/UserScript==
-
-
// The name of the fields we are going to look for.
-
var ssn_fields = new Array(
-
['ILoginForm.SSN1_KEY', 3],
-
['ILoginForm.SSN2_KEY', 2],
-
['ILoginForm.SSN3_KEY', 4]
-
);
-
// Current field.
-
var current_field = 0;
-
-
function goToNextField()
-
{
-
// Stop right there.
-
if (current_field> 2)
-
return;
-
-
// Field properties.
-
var id = ssn_fields[current_field][0];
-
var field_properties = document.getElementById(id);
-
// Current value.
-
var current_value = field_properties.value.length;
-
// Check the current field.
-
if (current_value == ssn_fields[current_field][1])
-
{
-
// Increase the current_field
-
current_field = current_field>= 2 ? 2 : current_field + 1;
-
// Move to the next field.
-
document.getElementById(ssn_fields[current_field][0]).focus();
-
}
-
-
// Only if the current field is not the last one.
-
setTimeout(goToNextField, 500);
-
}
-
-
// Start it.
-
setTimeout(goToNextField, 1000);
Filed under: PHP Snippets
Leave a reply