Created
November 15, 2020 15:14
-
-
Save HR/d03981ec53f8d7e56b0d98684e00f6b0 to your computer and use it in GitHub Desktop.
Amazon Invoice download
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
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