Last active
November 29, 2023 11:25
-
-
Save lapo-luchini/1251a02d531641c644b13f89d2f159f8 to your computer and use it in GitHub Desktop.
Download all CSV invoices from Hetzner
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Go to your account's invoice page, then open the console and execute this script, once per "page" of invoices.