An occasional outlet for my thoughts on life, technology, motorcycles, backpacking, kayaking, skydiving...

Monday, April 10, 2006

I wrote my first bookmarklet. It’s pretty cool, if I may say so.

I don't have much time to get into the details. I'll rewrite this later.

If you use Bank of America, you can use this on the page "Bill Pay & e-Bills" This bookmarklet navigates the DOM to find the "Outgoing Payments" table. It cycles through the table and adds a running (declining) total to the table. It's real simple, with now bells & whistles. I wrote it in about 2 hours. But, I always like to get out a calculator and subtract all my scheduled payments from my Available Funds ot see when I would run out of money if I didn't get any paychecks. (It's kind of morbid, but it makes me feel better.) I do this because When ever I am carrying a balance on a credit card, I like to spend nearly every penny each month. It's kind of nerve racking, but it's the best way to make sure those "bargins" that you just HAD to spend credit on remain bargins. (It's amazing how expensive things are when you add in the interest you pay!)
Update:
To use this bookmarklet, just drag this link --> Bank of America Burn Rate Calculator to your bookmark toolbar.

I also cleaned up the code a lot.

The Available Balance was $646.46
Here is the code:
[js]javascript:(
function(){
var getElementsByClassName=function(oElm,strTagName,strClassName){
var arrElements=(strTagName=='*'&&document.all)?document.all:oElm.getElementsByTagName(strTagName);
var arrReturnElements=new Array();
var oRegExp=new RegExp('(^|s)'+strClassName.replace(/-/g,'-')+'(s|$)');
for(var i=0;i if(oRegExp.test(arrElements[i].className)){
arrReturnElements.push(arrElements[i]);
}
}
return(arrReturnElements)
};
var funds=parseFloat(getElementsByClassName(document,'span','payfrommargin')[1].innerHTML.replace(/Avail. Funds $([0-9.,]+).*/,'$1').replace(/,/,''));
var table=getElementsByClassName(document,'table','mod1-bkgd2-hs')[1];
var cells=getElementsByClassName(table,'td','text1a');
for(x=1;x var bill=cells[x].innerHTML.replace(/$([0-9.,]+).*/,'$1').replace(/,/,'');
funds-=bill;
var fundsString=Math.ceil(funds*100).toString();
cells[x].innerHTML='$'+bill+'
$'+fundsString.substring(0,fundsString.length-2)+'.'+fundsString.substring(fundsString.length-2,fundsString.length);
}
}
)
();[/js]

Here it is on one line the way you have to enter in into Mozilla:
[js]javascript:(function(){var getElementsByClassName=function(oElm,strTagName,strClassName){var arrElements=(strTagName=='*'&&document.all)?document.all:oElm.getElementsByTagName(strTagName);var arrReturnElements=new Array();var oRegExp=new RegExp('(^|s)'+strClassName.replace(/-/g,'-')+'(s|$)');for(var i=0;i$'+fundsString.substring(0,fundsString.length-2)+'.'+fundsString.substring(fundsString.length-2,fundsString.length);}})();
[/js]

2 comments:

  1. Hey, this is a pretty cool bookmarklet. Nice Effort with the DOM.

    ReplyDelete
  2. to research and develop via trial and error.

    It was a lot of fun, and the result is an amazing time saver for me. I just wanted to write this up and even expose "my Personal Finances" to encourage others to write tools that make their lives better.

    I just wish I could find a bookmarklet site that lets other post their bookmarklets. All the ones I find are lists of bookmarklets from the site owner, with no way to submit yours. Hmmm.

    ReplyDelete

Followers

About Me

My photo

Believe it or not, I've never been to jail. Not even for a night. I quit going to bars by the time my fake ID was unnecessary, and I quit hacking into businesses and governments once they started paying me.

Now I just provide for my family and try not to notice politics. I get too angry when I watch how much of my income is taken from me, how it is used, and who is doing it. For the same reason, I can't bear to acknowledge celebrities.

After high school, I went to U of K but the outdated computer engineering curriculum and the seemingly endless amounts of money to be made with my internet specific skills drew me to larger tech markets. I have worked in Silicon Valley, New York City, and have settled in Atlanta.