Skip to content

Instantly share code, notes, and snippets.

@veltman
Created February 11, 2014 22:41
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 veltman/8945792 to your computer and use it in GitHub Desktop.
Save veltman/8945792 to your computer and use it in GitHub Desktop.
Get all PDF links on a page
Array.prototype.slice.call(document.getElementsByTagName("a"), 0 ).filter(function(d){ return d.href.match(/[.]pdf$/i);}).map(function(d){ return d.href.match(/^https?:/i) ? d.href : (window.location.href.match(/\/^/) ? window.location.href+d.href : window.location.href.split("/").slice(0,-1).join("/")+"/"+d.href ); }).join("\n");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment