Skip to content

Instantly share code, notes, and snippets.

@bennylope
Created May 27, 2020 18:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bennylope/cbab30c941ab5b7935bd93911bc88a4b to your computer and use it in GitHub Desktop.
Save bennylope/cbab30c941ab5b7935bd93911bc88a4b to your computer and use it in GitHub Desktop.
Download your Papertrail gzipped archives
/*
Copy and paste into your browser console window after loading
your archives page, e.g. with a selected long date range.
Original: https://www.reddit.com/r/javascript/comments/5my92r/console_script_to_click_all_download_links_on_a/dc7cktr/
The problem I had with my first attempt was that there was no delay,
so I was only downloading the last entry on the page. The linked
solution above pointed to the problem (each subsequent request was
killing the preceding request) which was including a delay. Here
I used 1.5 seconds, which should probably be bumped up just a little
bit since it missed a few entries.
Make sure your browser handles *.gz files by downloading them without
any prompt.
*/
var elements = document.getElementsByClassName("right btn-links sm");
var counter = 0;
var interval = setInterval(function () {
elements[counter].children[0].click();
counter++;
if ( counter > elements.length ) {
clearInterval(interval);
}
}, 1500);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment