Last active
May 11, 2022 09:39
-
-
Save Pezmc/016eab7b07cd8462622a4b63a88ef2f5 to your computer and use it in GitHub Desktop.
Download all invoices/bills from Xero
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
/* | |
* 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