Skip to content

Instantly share code, notes, and snippets.

@cfg
Last active May 23, 2019 16:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cfg/40a4a24377d54b2d43eb to your computer and use it in GitHub Desktop.
Save cfg/40a4a24377d54b2d43eb to your computer and use it in GitHub Desktop.
Crudely extract custom emoji from a Slack web instance. Load the web interface for the Slack instance and paste this into the developer console.
jQuery('#main_emo_menu').click();
jQuery('button[aria-label=Custom]').click();
jQuery('.p-emoji_picker__list').css('min-height', '900px');
jQuery('.p-emoji_picker__list_container').parents('.ReactModal__Content.ReactModal__Content--after-open.popover').css('top', '0px');
jQuery('.p-emoji_picker__list_container').css('max-height', '100%');
jQuery('.p-emoji_picker__content .p-emoji_picker__input_container').hide();
var emoji = [];
jQuery('.p-emoji_picker__heading:contains("Custom")').parent().next('.p-emoji_picker__list').find('a.p-emoji_picker__list_item').each( function( ix, el ) {
try {
el = jQuery( el );
var name = el.data('name').replace( /:/g, '' );
var re = new RegExp( '\\b' + name + '\\b', 'g' );
var aliases = el.data('names').replace( /:/g, '' ).replace( re, '' ).trim();
var bg = el.find('.emoji').css('backgroundImage');
if ( ! bg ) {
return;
}
bg = bg.replace(/.*\s?url\([\'\"]?/, '').replace(/[\'\"]?\).*/, '');
var extension = bg.match( /(\.\w+)$/ );
if( !extension.length ) {
console.log( 'Could not find extension for image %s', bg );
extension = '.jpg';
} else {
extension = extension[0];
}
var out = name + extension;
var curl = 'curl -o "' + out + '" "' + bg + '"';
var obj = {
name: name,
aliases: aliases,
source: bg,
cmd: curl
};
emoji.push( obj );
} catch(e) {
debugger;
}
} );
e = JSON.stringify( emoji );
// copy( e );
console.log('Run `copy(e);` to copy the Slack emoji to your clipboard');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment