Add Amazon Invoice Downloader script

Add script to automate the download of Amazon invoices from the order history page. The script searches for invoices and downloads them automatically.
This commit is contained in:
2023-12-30 18:26:26 +01:00
commit 021981befe
2 changed files with 43 additions and 0 deletions

View File

@@ -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;
});