Last active
September 26, 2015 06:27
-
-
Save atomicules/1053858 to your computer and use it in GitHub Desktop.
Coffeescript source code for a bookmarklet to generate QIF files for SMILE bank.
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
#Bookmarklet to generate QIF for Recent Item and Previous Statement pages on SMILE.co.uk bank | |
#Will (try to) open a new popup window where you will have to either: | |
#a) Copy text from and paste to text editor (Chrome) | |
#b) Save the page as a text file (Firefox) | |
# | |
#Written in Coffescript, but just use http://javascriptcompressor.com/ to compress the | |
#compiled javascript so you have a bookmarklet. | |
data = document.getElementsByClassName("summaryTable")[0].children[1].children | |
qif = "!Type:Bank<br />" | |
transaction = (row) -> | |
unless row.childElementCount is 0 #skip last row on Recent Items page | |
unless row.children[1].innerHTML.trim() is "BROUGHT FORWARD" #skip first row on Previous Statements page | |
qif += "D"+row.children[0].innerHTML.trim()+"<br />" | |
qif += "P"+row.children[1].innerHTML.trim()+"<br />" | |
#Then need transaction amount | |
unless row.children[2].innerHTML.trim() is " " | |
qif += "T"+row.children[2].innerHTML.trim().substring(1)+"<br />" | |
else | |
qif += "T-"+row.children[3].innerHTML.trim().substring(1)+"<br />" | |
qif += "^<br />" | |
transaction(row) for row in data | |
window.open("data:text/html;charset=utf-8,"+qif) | |
undefined #To get the void 0 bit so doesn't affect current window. |
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
var data,qif,row,transaction,_i,_len;data=document.getElementsByClassName("summaryTable")[0].children[1].children;qif="!Type:Bank<br />";transaction=function(row){if(row.childElementCount!==1){if(row.children[1].innerHTML.trim()!=="BROUGHT FORWARD"){qif+="D"+row.children[0].innerHTML.trim()+"<br />";qif+="P"+row.children[1].innerHTML.trim()+"<br />";if(row.children[2].innerHTML.trim()!==" "){qif+="T"+row.children[2].innerHTML.trim().substring(1)+"<br />"}else{qif+="T-"+row.children[3].innerHTML.trim().substring(1)+"<br />"}return qif+="^<br />"}}};for(_i=0,_len=data.length;_i<_len;_i++){row=data[_i];transaction(row)}window.open("data:text/html;charset=utf-8,"+qif);void 0; |
Ok. Fixed this. Tested and works for me. The problem was a slight change in mark-up for the last row of the table in "Recent Items". I.e. there is now a table row with just one element.
Wonder if this needs updating for the recent changes?
Minor tweak. Now seems to be called "summaryTable" instead of "summarytable"
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
hey, nice work! This would save me a lot of time.... but... Doesn't work at the moment, I presume because there are now two summaryTables. Fancy fixing it? Cheers!