Skip to content

Instantly share code, notes, and snippets.

@burnsjeremy
Forked from dogeared/00_README
Last active April 6, 2018 19:23
Show Gist options
  • Save burnsjeremy/baf7b948640b5588ae1f849c64e82fd6 to your computer and use it in GitHub Desktop.
Save burnsjeremy/baf7b948640b5588ae1f849c64e82fd6 to your computer and use it in GitHub Desktop.
Extracting / Exporting custom emoji from Slack
This can help you copy custom emojis from one team to another team in slack easily.
I wanted to give my new team some updates to their emojis b/c they were missing the usual emojis that I was used to seeing.
I went to google and found someone had came up with something that could work but I made some updates to make it easier to use and used some suggestions from the commenters to finish the script up also.
*******
This builds off the excellent work of @lmarkus.
The scripts below can be used in conjunction with the Slack Emoji Tools Google Chrome extension to export emojis from
one Slack team and import into another team.
OG work here: https://gist.github.com/lmarkus/8722f56baf8c47045621
********
Then the next version was found here: https://gist.github.com/dogeared/f8af0c03d96f75c8215731a29faf172c
********
Thanks to all commenters and @lmarkus and @dogeared for their work also. I have made some updates that make it a little easier to handle these items.
// Login to your team through the browser.
// Go to: https://<team name>.slack.com/customize/emoji
// Run this on the browser's dev tools javascript console
var emojis = $('.emoji_row');
var numEmojis = emojis.size();
var pre = document.createElement('pre');
pre.append('[\n');
emojis.each(function (index) {
var url = $(this).find('td:nth-child(1) span').attr('data-original');
var extension = url.substring(url.lastIndexOf('.'));
var name = $(this).find('td:nth-child(2)').html().replace(/:|\s/g, '');
pre.append(JSON.stringify({name: name, extension: extension, url: url}));
if (index == (numEmojis-1)) {
pre.append('\n]');
} else {
pre.append(',\n');
}
});
$('body').empty().append(pre);
// Now, in the body of the browser you'll see the json representation of all the custom emoji data for that team.
// copy and paste the json into a file and use with 02_download.sh
#!/usr/bin/env bash
# Use:
# Make this file executable, and feed it the results from the Slack emoji URL dump. Files will be downloaded to `output`
# chmod +x download.sh
# ./download.sh emojiURLs.txt
#
# Note: This depends on the jq utility for parsing json from the command line - https://stedolan.github.io/jq/
# You can install with homebrew easily on mac, brew install jq. If you need another way there is a webinterface you can
# Use to print out all the curl commands and run your mkdir below. Then go to https://jqplay.org then follow instructions below.
# 1. Paste json code into JSON box.
# 2. Paste this into filter field: .[] | "curl -s -o output/\(.name)\(.extension) \(.url)"
# 3. Check raw output on result field to remove quotes.
# 4. Copy curl commands and paste into terminal.
# 5. This will let you out of installing something you may not use again.
# 6. Here is a shared snippet of some custom emojis that I grabbed with the extract.js code above: https://jqplay.org/s/srPWnELEiS
# Note: I can't guarantee that the sharable snippet is saved forever so no promises that the link above will always work,
# If it is broken just let me know and I can update it if you need it.
mkdir -p output;
jq -r '.[] | "curl -s -o \"output/\(.name)\(.extension)\" \"\(.url)\""' $1 | \
while read -r line; do eval "$line"; done
# You can now drag and drop all the emoji files in the output folder to the Buld Emoji Uploader space that you'll see on
# the https://<team>.slack.com/customize/emoji page if you've installed the chrome extension
# https://chrome.google.com/webstore/detail/slack-emoji-tools/anchoacphlfbdomdlomnbbfhcmcdmjej
# Or you can choose the ones you want, either way you have the emoji files that can be added in Slack now.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment