Created
March 2, 2012 12:07
-
-
Save iamntz/1958038 to your computer and use it in GitHub Desktop.
ing greasemonkey script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name ing | |
// @namespace ing.ro | |
// @include https://www.homebank.ro/* | |
// @include http://www.homebank.ro/* | |
// ==/UserScript== | |
var ING_USER = 'xxxxxxxxxx'; | |
// Add jQuery | |
(function(){ | |
GM_wait(); | |
})(); | |
// Check if jQuery's loaded | |
function GM_wait() { | |
if (typeof unsafeWindow.jQuery == 'undefined') { | |
window.setTimeout(GM_wait, 100); | |
} else { | |
unsafeWindow.jQuery = unsafeWindow.jQuery.noConflict(true); | |
letsJQuery(); | |
} | |
} | |
// All your GM code must be inside this function | |
function letsJQuery() { | |
var $jQuery = unsafeWindow.jQuery; | |
var ING_ntz = function(){ | |
this.init(); | |
} | |
ING_ntz.prototype = { | |
init: function(){ | |
var $t = this; | |
$t.user = document.getElementsByName('username')[0] || null, | |
$t.pass = document.getElementsByName('password')[0] || null; | |
$t.iban = document.getElementById('paymentForm:ibanCountryCode') || null; | |
if( $t.user ){ | |
$t.login(); | |
} | |
if( $t.iban ){ | |
$t.fakeIBAN(); | |
} | |
}, // init | |
login: function(){ | |
var $t = this; | |
$jQuery('#slider, .content > .line').remove(); | |
$jQuery('.login-box').css({ | |
'float':'none', | |
'margin':'50px auto' | |
}) | |
$t.user.value = ING_USER; | |
window.setTimeout(function(){ | |
$t.pass.focus(); | |
}, 50); | |
}, // login | |
fakeIBAN: function(){ | |
var $t = this; | |
var $ = $jQuery; | |
var dl = $($t.iban).closest('dl') | |
var newDl = $('<dl>'); | |
var dd = $('<dd/>'); | |
var iban = [ | |
$t.el('paymentForm:ibanCountryCode'), | |
$t.el('paymentForm:ibanCheckSum'), | |
$t.el('paymentForm:ibanSwift'), | |
$t.el('paymentForm:ibanAccountNo') | |
]; | |
$('<input id="fakeIBAN"/>').bind('blur', function(){ | |
var val = $(this).val() || '', | |
fakeIBAN = val.replace(/\s|\-/g, ''); // stergem spatii si cratime | |
console.log(fakeIBAN); | |
if( fakeIBAN.length == 24 ){ | |
iban[0].value = fakeIBAN.substr(0,2); | |
iban[1].value = fakeIBAN.substr(2,2); | |
iban[2].value = fakeIBAN.substr(4,4); | |
iban[3].value = fakeIBAN.substr(8,16); | |
iban[3].focus(); | |
window.setTimeout( function(){ iban[3].blur(); }, 100 ); | |
} | |
}).appendTo(dd); | |
$('<dt/>').text('Full IBAN').appendTo( newDl ); | |
dd.appendTo( newDl ); | |
newDl.insertBefore(dl); | |
}, // fakeIBAN | |
el:function( e ){ return document.getElementById( e ) || null; } | |
}; | |
myING = new ING_ntz( ING_USER ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment