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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | // ==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); |
Leave a reply