Skip to content

Instantly share code, notes, and snippets.

@egorvinogradov
Created November 11, 2014 00:31
Show Gist options
  • Select an option

  • Save egorvinogradov/d90481c6f1e22c838c0b to your computer and use it in GitHub Desktop.

Select an option

Save egorvinogradov/d90481c6f1e22c838c0b to your computer and use it in GitHub Desktop.
var AMOUNT_TO_ADD = 3000;
function formatNumber(number, separator){
var str = number.toString();
var a = str.split('.')[0];
var b = str.split('.')[1];
var formatted = a.replace(/\d(?=(\d{3})+$)/g, "$&" + separator);
if ( b ) {
if ( b.length < 2 ) {
b+= '0';
}
formatted += '.' + b;
}
return formatted;
}
$('.balance.TL_NPI_Amt').each(function (i, el) {
var element = $(el);
var value = element.html();
var n = +value.replace(',', '');
if ( n > 1000 && element.parents().is('.processing') ) {
console.log('Changed :', n, ':', el);
element.html( formatNumber(n + AMOUNT_TO_ADD, ',') );
}
});
var record1 = $('.amount.positive').first();
record1.add(record1.next()).each(function(i, el){
var element = $(el);
element.html( element.html().replace(/^\d/, '4') );
});
function replaceTotal(elements){
elements.each(function(i, el){
var element = $(el);
var value = element.html();
if ( value.split('.')[0].replace('$', '').replace(',', '').length > 3 ) {
element.html( value.replace(/\$\d/, '$$4') );
}
});
}
replaceTotal( $('.fl-rt.bold.dumb-ie-amt-fix.TL_NPI_Amt, .extracted-balance, .TL_NPI_L1') );
$('#fsd-li-accounts').mouseover(function(){
console.error('>>', $('.TL_NPI_L1, .fsd-ao-amount.TL_NPI_Amt'))
replaceTotal( $('.fsd-ao-amount.TL_NPI_Amt') );
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment