Created
July 8, 2024 04:02
-
-
Save achadha235/5ef9dee79eab888d508a0af888ea60f1 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