Skip to content

Instantly share code, notes, and snippets.

@Rockbass
Forked from thisisrachelramos/00_README
Created August 28, 2018 13:06
Show Gist options
  • Save Rockbass/f3b272f40b28e39b742adee9afae69f4 to your computer and use it in GitHub Desktop.
Save Rockbass/f3b272f40b28e39b742adee9afae69f4 to your computer and use it in GitHub Desktop.
Extracting / Exporting custom emoji from Slack
This builds off the excellent work of @lmarkus.
The scripts below can be used in conjunction with the Neutral Face Emoji Tools Google Chrome extension to (bulk!)
export emojis from one Slack team and import into another team:
https://chrome.google.com/webstore/detail/neutral-face-emoji-tools/anchoacphlfbdomdlomnbbfhcmcdmjej
Original work here: https://gist.github.com/lmarkus/8722f56baf8c47045621
Steps:
1) Run js in dev tools
2) Save json object in a txt file
3) Run bash script
4) Drag and drop all of the downloaded emojis in the bulk uploader
enabled through the chrome extension
#!/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 downloadSlackEmojis.sh
# ./downloadSlackEmojis.sh emojiURLs.txt
#
# Note: This depends on the jq utility for parsing json from the command line - https://stedolan.github.io/jq/
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 Bulk 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/neutral-face-emoji-tools/anchoacphlfbdomdlomnbbfhcmcdmjej
// 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
// This code scrolls to bottom of page to load all emojis
// (bc of virtualized list not revelaing all of the elements).
// Slow connections may wish to adjust the above factor past 2.5
var scrollTime = $(document).height() * 2.5
$("html, body").animate({ scrollTop: $(document).height() }, scrollTime);
var emojis = $('.emoji_row');
var numEmojis = emojis.size();
var pre = document.createElement('pre');
pre.append('[\n');
// After waiting for the scroll, grab url/name for each emoji
// and populate a json object that will appear at the bottom of the page
window.setTimeout(function() {
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');
}
});
console.log(eFile);
}, scrollTime + 1000);
// Now, at the bottom of the page you'll see the json representation of all the emoji data
// copy and paste the json into a file (named "emojiURLs.txt" in "downloadSlackEmojis.sh" instructions)
// and use with downloadSlackEmojis.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment