« De ce nu este Linux (Ubuntu) potrivit pentru un enduser?
Link-urile săptămânilor 20 feb – 4 martie »
ING Homebank v.4 & Greasemonkey
Long story short, pe lângă faptul că se pune userul automat, se mai întâmplă următoarele:
- Prima pagină devine mult mai practică, afișând informațiile importante pentru homebank;
- Apare un câmp nou în pagina „plată nouă în lei” în care poți băga IBAN-ul complet. acest IBAN poate avea spații și cratime; va fi stripped down.
Asta pentru că ING are grijă la UX.
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 ); | |
} |
Codul e pus pe gist pentru că am observat că uneori WordPress parsează aiurea exemplele de cod. Și pentru că e prea lung. Știu că uneori îngreunează pagina, dar… Momentan asta e cea mai bună soluție.
Enjoy!
Edit: dacă nu știi cum se instalează, caută în posturile mai vechi.
Edit 2:
![2012-03-02_1438[1]](http://content.iamntz.com/wp-content/uploads/2012/03/2012-03-02_14381.png)
Full IBAN
- Posted in:
- Tips & Tricks
Cred ca e o mica greseala in script, cand se populeaza cele 4 campuri din fakeIBAN se pierd primele 2 cifre din ultima componenta. Mai exact linia:
iban[3].value = fakeIBAN.substr(10,16);
ar trebui sa fie
iban[3].value = fakeIBAN.substr(8,16);
@Ciprian: mulțumesc, am actualizat codul.
Din nu știu ce motiv, am sărit peste comentariul tău (deh, dacă sunt prea multe
), de asta mi-a și trebuit o lună să modific.
Nu-i nici o problema, eu iti multumesc pentru restul de linii :), chiar e folositor scriptul.