Skip to content

Instantly share code, notes, and snippets.

@lapo-luchini
Last active November 29, 2023 11:25
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 lapo-luchini/1251a02d531641c644b13f89d2f159f8 to your computer and use it in GitHub Desktop.
Save lapo-luchini/1251a02d531641c644b13f89d2f159f8 to your computer and use it in GitHub Desktop.
Download all CSV invoices from Hetzner
let elem = Array.prototype.slice.call(document.getElementsByClassName('btn-download')).map(e=>e.href).filter(u=>u.endsWith('/csv'));
let numbers = elem.map(u=>/invoice[/]([^/]+)/.exec(u)[1]);
let filename = 'invoice-' + numbers[0] + '-' + numbers[numbers.length - 1] + '.csv';
let csv = '';
for (let url of elem)
csv += await (await fetch(url)).text();
let a = document.createElement("a");
a.download = filename;
a.href = a.href = "data:text/csv,"+encodeURIComponent(csv);
a.click();
@lapo-luchini
Copy link
Author

Go to your account's invoice page, then open the console and execute this script, once per "page" of invoices.

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