Skip to content

Instantly share code, notes, and snippets.

@keturn
Forked from dogeared/00_README
Last active June 12, 2018 06:44
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save keturn/9aca9dab0c48ddc007645f46c773bd3e to your computer and use it in GitHub Desktop.
Save keturn/9aca9dab0c48ddc007645f46c773bd3e to your computer and use it in GitHub Desktop.
Extracting / Exporting custom emoji from Slack
This builds off the excellent work of @lmarkus & @dogeared.
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.
Original work here:
* https://gist.github.com/lmarkus/8722f56baf8c47045621
* https://gist.github.com/dogeared/f8af0c03d96f75c8215731a29faf172c
// 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 emojiList = emojis.map(function () {
var url = $(this).find('td:nth-child(1) span').attr('data-original');
if (url.length > 512) { // bonkers data-urls
return null
}
var extension = url.substring(url.lastIndexOf('.'));
var name = $(this).find('td:nth-child(2)').html().replace(/:|\s/g, '');
return {name, extension, url}
}).get();
function curlEmoji({name, extension, url}) {
return `url "${url}"
output "${name}${extension}"
`
}
function curlConfigFilename() {
var slackHost = new URL(boot_data.team_url).hostname.split('.', 1)[0]
return `${slackHost}-emoji.curl.cfg`
}
var curlOptions = emojiList.map(curlEmoji)
var output = new Blob(curlOptions, {type: "text/plain"})
var downloadLink = document.createElement("a")
downloadLink.href = URL.createObjectURL(output)
downloadLink.download = curlConfigFilename()
downloadLink.append(`⬇️ Download: ${curlConfigFilename()}`)
$('#custom_emoji').before(downloadLink)
downloadLink.click()
/**
* this will download a curl.cfg file
* use it with curl as
*
* curl --config ourteam-emoji.curl.cfg
*
* and files will be downloaded to the current directory.
*
* 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
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment