Skip to content

Instantly share code, notes, and snippets.

@nakami
Last active January 30, 2019 21:44
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 nakami/660aa0841ae60d558935b2ea2531fb7b to your computer and use it in GitHub Desktop.
Save nakami/660aa0841ae60d558935b2ea2531fb7b to your computer and use it in GitHub Desktop.
Add high resolution download button on the pinkbike POD page
// run on https://www.pinkbike.com/photo/podlist/
// high res links look like this: https://lp1.pinkbike.org/p0pb<ID>/<ID>.jpg
// get all li-tags with 'inElm' class
var li_inElms = document.querySelectorAll('li.inElm')
// iterate over all li-tags
for(var i = 0; i < li_inElms.length; i++){
// get the id
var link = li_inElms[i].getElementsByTagName('a')[0].getAttribute('href');
var link_splitted = link.split("/");
var id = link_splitted[4];
// build the high res link
var dl_link = 'https://lp1.pinkbike.org/p0pb' + id + '/' + id + '.jpg';
// create a new 'a' element
var new_a = document.createElement("a");
new_a.setAttribute('href', dl_link);
new_a.setAttribute('download', id + ".jpeg");
new_a.innerHTML = 'download';
// add 'a' to li element
li_inElms[i].appendChild(new_a);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment