Skip to content

Instantly share code, notes, and snippets.

@frankgeerlings
Forked from rudiedirkx/ing-creditcard-export.js
Last active December 30, 2017 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save frankgeerlings/edbd3935f858112437eaa8eb270a1d17 to your computer and use it in GitHub Desktop.
Save frankgeerlings/edbd3935f858112437eaa8eb270a1d17 to your computer and use it in GitHub Desktop.
Mijn ING creditcard statement export as text, including detail rows
javascript: (function(f, a) {
f = new Blob(
[
[].map.call(document.querySelectorAll('#dscardsdetailsandtransactions tr.riaf-datatable-contents, #dscardsdetailsandtransactions td.riaf-datatable-details-contents'),
tr => tr.querySelector('table') ? [].map.call(tr.querySelectorAll('tr'),
detail =>
' ' + detail.querySelector('td:first-of-type').textContent.trim() + ": " +
detail.querySelector('td:last-of-type').textContent.trim()
).join('\r\n')
: ["Datum: " + tr.querySelector('td.riaf-datatable-column-date').textContent.trim(),
"Bedrag: " + tr.querySelector('td.riaf-datatable-column-amount').textContent.trim(),
"Bij/af: " + (tr.querySelector('.riaf-datatable-icon-crdb-cr') ? 'Bij' : 'Af')].join('\r\n')
).join('\r\n\r\n')], {type: 'text/plain'});
a = document.createElement('a');
a.download = 'trans.txt';
a.href = URL.createObjectURL(f);
a.click();
})(); void(0)
@RW83
Copy link

RW83 commented Dec 30, 2017

Thanks! Required everything on a single line and filenames related to timerange:

javascript: (function(f, a) {
	var name = (document.querySelectorAll('div.riaf-form-container-header')[1].textContent.trim().replace('Huidige periode: ', '').replace('/', '')).split(" ").join("_") + '.txt'
	
	f = new Blob(
		[
		[].map.call(document.querySelectorAll('#dscardsdetailsandtransactions tr.riaf-datatable-contents, #dscardsdetailsandtransactions td.riaf-datatable-details-contents'),
		tr => tr.querySelector('table') ? 
			[].map.call(tr.querySelectorAll('tr'),
						detail => ''
							).join('')
		 : [ 
		    '"' + tr.querySelector('td.riaf-datatable-column-date').textContent.trim(),
		    tr.querySelector('td.riaf-datatable-column-text').textContent.trim(),
			tr.querySelector('td.riaf-datatable-column-amount').textContent.trim(),
			(tr.querySelector('.riaf-datatable-icon-crdb-cr') ? 'Bij' : 'Af'),
			tr.querySelector('td:last-of-type').textContent.trim(),
			'\r\n'
			].join('";"') 
		).join('') ] , {type: 'text/plain'});
	a = document.createElement('a');
	a.download = name;
	a.href = URL.createObjectURL(f);
	a.click();
})(); void(0)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment