Last active
August 23, 2017 16:30
-
-
Save sudosanet/7a54673b9cecf6b9b26664bd07ad2ff9 to your computer and use it in GitHub Desktop.
This file contains 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
if(!document.body.innerHTML.match(/jszip/)){ | |
var ele = document.createElement("script"); | |
ele.type = "text/javascript"; | |
ele.src = "https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"; | |
document.body.appendChild(ele); | |
var ele2 = document.createElement("script"); | |
ele2.type = "text/javascript"; | |
ele2.src = "https://fastcdn.org/FileSaver.js/1.1.20151003/FileSaver.min.js"; | |
document.body.appendChild(ele2); | |
setTimeout(makezip,100); | |
} | |
else { | |
makezip(); | |
} | |
function makezip() { | |
var zip = new JSZip(); | |
var img = zip.folder("images"); | |
var f = $('img').length; | |
for(var i=0;i<f;i++){ | |
if($('img')[i].src.match(/data:image/) && $('img')[i].alt!=="noise"){ | |
var data = $('img')[i].src.replace("data:image/png;base64,",""); | |
img.file(i + ".png", data, {base64: true}); | |
} | |
if(i===f-1){ | |
zip.generateAsync({type:"blob"}).then(function(content) { | |
saveAs(content, "img.zip"); | |
}); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment