Skip to content

Instantly share code, notes, and snippets.

@smichaelsen
Created February 3, 2016 22:48
Show Gist options
  • Save smichaelsen/212ae3b098c285c71f68 to your computer and use it in GitHub Desktop.
Save smichaelsen/212ae3b098c285c71f68 to your computer and use it in GitHub Desktop.
Number26 running balance
// this script displays the running balance for each day in the transaction list of your number26 bank account
// attention: you should not execute any random code you found in the internet on your online banking!
var getBalance = function(string) {
var amountParts = string.split(',');
return parseInt(amountParts[0]) + parseInt(amountParts[1]) / 100;
};
var getDayOverviewNodes = function() {
return $('.activities').find('.node.delim');
};
var renderCurrentBalance = function() {
var nodes = getDayOverviewNodes();
nodes.find('h3.running').remove();
var balance = getBalance($('.infos').find('h5').text().split('Guthaben')[1]);
nodes.each(function(){
var node = $(this);
var nodeBalance = getBalance(node.find('h3').text());
var running = $('<h3 />').addClass('running').html(balance.toFixed(2) + ' <b>€</b>');
if (balance >= 0) {
running.addClass('load');
} else {
running.addClass('expense');
}
node.find('h2').after(running);
balance -= nodeBalance;
});
};
renderCurrentBalance();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment