Skip to content

Instantly share code, notes, and snippets.

@EntranceJew
Last active June 16, 2017 15:15
Show Gist options
  • Save EntranceJew/1a8efdfaa9073d052513f9fa8d7e3bcc to your computer and use it in GitHub Desktop.
Save EntranceJew/1a8efdfaa9073d052513f9fa8d7e3bcc to your computer and use it in GitHub Desktop.
if you're on a page fulla emojis, lazyload them all and this will download them all [will take some time]
// WARNING: this will take some time, chrome might hiccup, you might be prompted in the URL bar to run unsafe scripts
function saveFile(url, filename) {
// Get file name from url.
var xhr = new XMLHttpRequest();
xhr.responseType = 'blob';
xhr.onload = function() {
var a = document.createElement('a');
a.href = window.URL.createObjectURL(xhr.response); // xhr.response is a blob
a.download = filename; // Set the file name.
a.style.display = 'none';
document.body.appendChild(a);
a.click();
delete a;
};
xhr.open('GET', "https://crossorigin.me/" + url);
xhr.send();
}
var z = "", t = "", u = "";
$("li > a > img").each( function( k, v ){
u = $(v).attr("srcset").split(" ")[0];
t = $(v).parent("a").attr("href").split("/");
t.pop();
saveFile(u, t.pop() + ".png");
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment