Skip to content

Instantly share code, notes, and snippets.

@HR
Created November 15, 2020 15:14
Show Gist options
  • Save HR/d03981ec53f8d7e56b0d98684e00f6b0 to your computer and use it in GitHub Desktop.
Save HR/d03981ec53f8d7e56b0d98684e00f6b0 to your computer and use it in GitHub Desktop.
Amazon Invoice download
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)
window.open(el.href, '_blank')
});
}
finda('Invoice').forEach((e, i, arr) => {
setTimeout(() => {
e.click();
console.log(i, e);
if (i === arr.length - 1) {
setTimeout(() => downloada('Invoice 1'), 1000)
setTimeout(() => downloada('Invoice 2'), 2000)
}
}, sleep);
sleep += sleepInterval;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment