Files
Frederic Beckmann 021981befe 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.
2023-12-30 18:26:26 +01:00

37 lines
959 B
JavaScript

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