Skip to content

Instantly share code, notes, and snippets.

@stoft
Last active June 3, 2021 08:17
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 stoft/30a44466bfa5eef5b9394e6a29ca2375 to your computer and use it in GitHub Desktop.
Save stoft/30a44466bfa5eef5b9394e6a29ca2375 to your computer and use it in GitHub Desktop.
Avanza Extract
console.log([...document.getElementsByTagName('table')]
//AVANZA
.filter(t => t.caption && (t.caption.innerText.toLowerCase().includes("fonder") || t.caption.innerText.includes("Certifikat")))
.map(t => [...t.getElementsByTagName('tbody')]
.map(tb => [...tb.getElementsByTagName('tr')]
.map(tr =>
(tr.cells[2].innerText.replace(/Superräntan\s?$/,"")
+ `\t` + tr.cells[8].innerText.replace(/\s/g,"")
+ "\t" + tr.cells[3].innerText))))
.reduce((acc, e) => e[0].concat(acc).join("\n")
, ["Cash\t" + document.getElementsByTagName('table')[0]
.tBodies[0].rows[0].cells[1]
.innerText.split(" ")[0].replace(/\s/,"")
.replace(/,/, ".")]));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment