Last active
May 20, 2023 06:08
-
-
Save molotow11/e2795a80a053f2de24127a16710beb58 to your computer and use it in GitHub Desktop.
Shopif admin download settings/files images
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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