Skip to content

Instantly share code, notes, and snippets.

@molotow11
Last active May 20, 2023 06:08
Show Gist options
  • Save molotow11/e2795a80a053f2de24127a16710beb58 to your computer and use it in GitHub Desktop.
Save molotow11/e2795a80a053f2de24127a16710beb58 to your computer and use it in GitHub Desktop.
Shopif admin download settings/files images
/**
* Script for put into console for download all images from Shopify /admin/settings/files?limit=250
* This will download new file with all images inside it
* Then you need to open this file and go to browser's parameters -> Save page -> Select an option for download full page
* Then the browser will download this page and create a folder with all images inside
*/
function fetchPageAssets() {
let images = document.querySelectorAll('img[src*=files]:not(img[src*=avatar])');
images.forEach(function(image) {
files.push('<a href="' + image.src.replace(/_60x60/, "") + '"><img src="' + image.src.replace(/_60x60/, "") + '"></a><br />');
});
}
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('<html>\n<body>')
fetchPageAssets()
files.push('</body>\n</html>\n')
downloadListFile()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment