Skip to content

Instantly share code, notes, and snippets.

@r8r
Forked from mubbo/shopify_files.js
Created October 11, 2021 12:17
Show Gist options
  • Save r8r/427b8300faaf3043dd270f24762af6f7 to your computer and use it in GitHub Desktop.
Save r8r/427b8300faaf3043dd270f24762af6f7 to your computer and use it in GitHub Desktop.
download images from shopify shop
function fetchPageAssets() {
let images = document.querySelectorAll('img[src*=files]');
images.forEach(function(image) {
files.push('<a href="' + image.src.replace(/_60x60/, "") + '"><img src="' + image.src.replace(/_60x60/, "") + '">');
});
}
function downloadListFile() {
let button = document.createElement("a");
let data = 'data:application/octet-stream;base64,' + window.btoa(files.join('\n'));
button.id = "download-file";
button.href = data;
button.download = "shopify-files.html";
document.querySelector("body").append(button);
button.click();
}
var files = []
files.push('\n')
fetchPageAssets()
files.push('\n\n')
downloadListFile()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment