Skip to content

Instantly share code, notes, and snippets.

@SabinT
Created July 16, 2019 02:02
Show Gist options
  • Save SabinT/1e1dd6303a75ffbd57ac2ec4ae904244 to your computer and use it in GitHub Desktop.
Save SabinT/1e1dd6303a75ffbd57ac2ec4ae904244 to your computer and use it in GitHub Desktop.
Download Cascade STP bike pictures in one shot from download page after purchase (medium/full)
function download(url, name) {
fetch(url)
.then(resp => resp.blob())
.then(blob => {
const url = window.URL.createObjectURL(blob);
const a = document.createElement('a');
a.style.display = 'none';
a.href = url;
a.download = name;
document.body.appendChild(a);
a.click();
window.URL.revokeObjectURL(url);
})
.catch(() => alert('Something went wrong.'));
}
var a = Array.from(document.getElementsByTagName("a"));
var full = a.filter(function(x) { return x.innerText == "Full-Sized"; });
medium = a.filter(function(x) { return x.innerText == "Medium"; })
full.map(x => download(x.href, "full" + x.href.substring(x.href.lastIndexOf('/') + 1) + ".jpg"))
medium.map(x => download(x.href, "medium" + x.href.substring(x.href.lastIndexOf('/') + 1) + ".jpg"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment