From 021981befeacaf7adc6d493db144f0f6a63e740f Mon Sep 17 00:00:00 2001 From: Frederic Beckmann Date: Sat, 30 Dec 2023 18:26:26 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Add=20Amazon=20Invoice=20Downloader?= =?UTF-8?q?=20script=20=E2=9C=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add script to automate the download of Amazon invoices from the order history page. The script searches for invoices and downloads them automatically. --- .../InvoiceDownlaoder.js | 36 +++++++++++++++++++ Amazon Invoice Downloader/readme.md | 7 ++++ 2 files changed, 43 insertions(+) create mode 100644 Amazon Invoice Downloader/InvoiceDownlaoder.js create mode 100644 Amazon Invoice Downloader/readme.md diff --git a/Amazon Invoice Downloader/InvoiceDownlaoder.js b/Amazon Invoice Downloader/InvoiceDownlaoder.js new file mode 100644 index 0000000..9b763c4 --- /dev/null +++ b/Amazon Invoice Downloader/InvoiceDownlaoder.js @@ -0,0 +1,36 @@ +var sleepInterval = 2200; +var sleep = 0; + +function finda(txt) { + let finds = Array.from(document.querySelectorAll("a")).filter((el) => + el.textContent.includes(txt) + ); + console.log(txt + ": " + finds.length); + return finds; +} + +function downloada(txt) { + finda(txt).forEach((el, i, arr) => { + console.log(`Downloading ${txt}...`, el.href); + const link = document.createElement("a"); + link.href = el.href; + link.target = "_blank"; + link.download = ""; + link.click(); + }); +} + +finda("Rechnung").forEach((e, i, arr) => { + setTimeout(() => { + e.click(); + console.log(i, e); + if (i === arr.length - 1) { + setTimeout(() => downloada("Rechnung 1"), 1000); + setTimeout(() => downloada("Rechnung 2"), 2000); + setTimeout(() => downloada("Rechnung 3"), 3000); + setTimeout(() => downloada("Rechnung 4"), 4000); + setTimeout(() => downloada("Rechnung 5"), 5000); + } + }, sleep); + sleep += sleepInterval; +}); diff --git a/Amazon Invoice Downloader/readme.md b/Amazon Invoice Downloader/readme.md new file mode 100644 index 0000000..625517a --- /dev/null +++ b/Amazon Invoice Downloader/readme.md @@ -0,0 +1,7 @@ +# Amazon Invoice Downloader + +## Description +This script downloads Amazon invoices from the Amazon website. It searches for the invoices in the order history and downloads them. + +## How to use +Simply paste the script into the console of the order history page. The script will automatically download all invoices of the current page. \ No newline at end of file