Skip to content

Instantly share code, notes, and snippets.

@Pezmc
Last active May 11, 2022 09:39
Show Gist options
  • Save Pezmc/016eab7b07cd8462622a4b63a88ef2f5 to your computer and use it in GitHub Desktop.
Save Pezmc/016eab7b07cd8462622a4b63a88ef2f5 to your computer and use it in GitHub Desktop.
Download all invoices/bills from Xero
/*
* Xero doesn't offer a way to natively download all attachments on a page.
* This script just manually opens every attachment and clicks the download button
*/
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
async function start() {
for (const pdf_button of document.querySelectorAll(".attachment a")) {
pdf_button.click();
await sleep(2000);
document.querySelector(".download-pdf").click();
await sleep(1000);
document.querySelector(".x-tool.x-tool-close").click();
await sleep(1000);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment