Skip to content

Instantly share code, notes, and snippets.

@achadha235
Created July 8, 2024 04:02
Show Gist options
  • Select an option

  • Save achadha235/5ef9dee79eab888d508a0af888ea60f1 to your computer and use it in GitHub Desktop.

Select an option

Save achadha235/5ef9dee79eab888d508a0af888ea60f1 to your computer and use it in GitHub Desktop.
Anna's archive auto download
/**
* 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