Skip to content

Instantly share code, notes, and snippets.

@theredpea
Created December 17, 2022 22:13
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 theredpea/210aa771fde20ea258ad4a4920246f4d to your computer and use it in GitHub Desktop.
Save theredpea/210aa771fde20ea258ad4a4920246f4d to your computer and use it in GitHub Desktop.
['2014', '2015','2016','2017','2018','2019','2020','2021','2022'].map(year=>{ return ['01','02','03','04', '05','06','07','08','09','10','11','12'].map(month=>[year, month]);}).flat()
.forEach(async ([year, month])=>{
let fetch_url = `https://www.mybenefitwallet.com/BW/activities/eStatement?year=${year}&month=${month}`;
// https://stackoverflow.com/a/24586168/1175496
await fetch(fetch_url)
.then(response => response.blob())
.then(blob => {
var url = window.URL.createObjectURL(blob);
var a = document.createElement('a');
a.href = url;
a.download = `${year}${month}__statements.pdf`;
document.body.appendChild(a); // we need to append the element to the dom -> otherwise it will not work in firefox
a.click();
a.remove(); //afterwards we remove the element again
})
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment