Saturday, October 19, 2013

Mint.com running total bookmarklet

Drag this link into your bookmarks bar, and click it when you're looking at your transactions on mint.com!

Annotated code below.




  1. // Inject jQuery
  2. (function() {
  3.   var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
  4.   ga.src = ('https:' == document.location.protocol ? 'https://' : 'http://') +'ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js';
  5.   var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  6. })();
  7.  
  8. // Poll until jQuery has loaded
  9. var interval = setInterval(function(){
  10.   if (typeof(jQuery) !== 'undefined'){
  11.     var total = 0;
  12.  
  13.     // Target the transaction list table and do some fancy string manipulation
  14.     $('#transaction-list-body').find('tr').each(function(){
  15.       total += parseFloat($(this).find('.money').text().replace('$','').replace(',','').replace('–','-'), 10);
  16.       $(this).append($('<td />').text(total.toFixed(2)));
  17.     });
  18.     clearInterval(interval);
  19.   }
  20. }, 100);





No comments: