Created
January 27, 2017 08:19
-
-
Save RadicalZephyr/7a643aae4fd1fa34b9f27cb835c81db2 to your computer and use it in GitHub Desktop.
Slack Emoji Liberator
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
// Download all the custom emoji your slack team have created! | |
// Start by going to the "Customize Emoji" screen for your Slack team. | |
// Open up a browser console and run the following JS | |
var pattern = new RegExp("https://emoji.slack-edge.com/.*?/([^/]+?)/[^/]+(\.png|jpg|gif)"); | |
function link_text (url) { | |
var match = pattern.exec(url); | |
if (match) { | |
var name = match[1]; | |
var extension = match[2]; | |
return "<a class='radz-download-link' download='"+ name + extension + "' href='"+url+"'>"+name+"</a>\n"; | |
} else { | |
return ""; | |
} | |
} | |
var urls = $.map($('td span[data-original]'), function (el) { return $(el).data('original'); }); | |
var total_html = urls.reduce(function (html_str, url) { html_str += link_text(url); }, ""); | |
// Copy the total_html string | |
// Open a url for one of the images so you have a web page on the same | |
// domain as where slack is serving the images from | |
open(urls[0]); // Or even better, inject an iframe with the | |
// appropriate url, and javascript and such... | |
// Edit the contents of total_html into this new page | |
// Now, in this window, run the following javascript | |
var links = Array.from(document.getElementsByClassName("radz-download-link")); | |
function downloadAndRemoveLink(link) { | |
console.log(link); | |
link.click(); | |
link.remove(); | |
} | |
function setupNextCall() { | |
setTimeout(function() { | |
if (links.length > 0) { | |
downloadAndRemoveLink(links.pop()); | |
setupNextCall(); | |
} | |
}, 200); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment