Skip to content

Instantly share code, notes, and snippets.

@rudiedirkx
Last active April 9, 2021 12:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save rudiedirkx/816fc0be0cb72f481f5afe496ea53fad to your computer and use it in GitHub Desktop.
Save rudiedirkx/816fc0be0cb72f481f5afe496ea53fad to your computer and use it in GitHub Desktop.
javascript: (function(f, a) {
f = new Blob(['"Date","Description","Amount"\n', [].map.call(queryAllShadow('[data-tag-name="ing-ow-expandable-item"]', queryAllShadow('[data-tag-name="ing-feat-transaction-period"]').reverse()[0]), row => ([
row.closest('.date-item').querySelector('time').getAttribute('datetime'),
row.querySelector('h5').textContent.trim(),
row.querySelector('h5 + strong').textContent.trim().replace(',', '.').replace('−', '-'),
]).map(col => '"' + col.replace(/"/g, '""') + '"').join(',')).join('\n')], {type: 'text/plain'});
a = document.createElement('a');
a.download = 'trans.csv';
a.href = URL.createObjectURL(f);
a.click();
})(); void(0)
queryAllShadow = function(selector, doc) {
const roots = [doc || document];
const addRoots = (root) => [root, ...root.querySelectorAll('*')].forEach(el => {
if (el.shadowRoot) {
roots.push(el.shadowRoot);
addRoots(el.shadowRoot);
}
});
addRoots(roots[0]);
const els = [];
roots.forEach(root => {
els.push(...root.querySelectorAll(selector));
});
return els;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment