Skip to content

Instantly share code, notes, and snippets.

@atomicules
Last active September 26, 2015 06:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save atomicules/1053858 to your computer and use it in GitHub Desktop.
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.
#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 "&nbsp;"
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.
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()!=="&nbsp;"){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;
@bensauer
Copy link

bensauer commented Jan 7, 2014

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!

@atomicules
Copy link
Author

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.

@atomicules
Copy link
Author

Wonder if this needs updating for the recent changes?

@atomicules
Copy link
Author

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