Skip to content

Instantly share code, notes, and snippets.

@RadicalZephyr
Created January 27, 2017 08:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RadicalZephyr/7a643aae4fd1fa34b9f27cb835c81db2 to your computer and use it in GitHub Desktop.
Save RadicalZephyr/7a643aae4fd1fa34b9f27cb835c81db2 to your computer and use it in GitHub Desktop.
Slack Emoji Liberator
// 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