-
-
Save Chokage/97b31f5952a8e1a7d702389b7b234d1b to your computer and use it in GitHub Desktop.
Anna's archive auto download
This file contains hidden or 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
/** | |
* Wait on a slow download page for Anna's archive and auto * click the Download button once it is ready | |
*/ | |
function checkAndClickDownloadButton() { | |
const intervalMs = 1000; | |
let clicked = false; | |
let intervalId; | |
function check() { | |
const btns = Array.from(document.getElementsByTagName("a")).filter( | |
(ele) => ele.innerText === "Download now" | |
); | |
if (btns.length > 0) { | |
btns[0].click(); | |
clicked = true; | |
} | |
if (clicked && intervalId) { | |
clearInterval(intervalId); | |
intervalId = null; | |
} | |
} | |
intervalId = setInterval(check, intervalMs); | |
} | |
checkAndClickDownloadButton() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment