Last active
August 29, 2015 14:04
-
-
Save jasisk/033edd6498648cf60a2e to your computer and use it in GitHub Desktop.
SUPERSEDED: jasisk/slack-emoji-randomizer - Slack userscript to replace all your emojis with 🦀
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function () { | |
function replaceText(msg, replaceWith) { | |
emoji.init_colons(); | |
msg = emoji.replace_emoticons_with_colons(msg); | |
return msg.replace(emoji.rx_colons, function (colonEmoji) { | |
var emojiKey = colonEmoji.substr(1, colonEmoji.length-2); | |
var replacement = emoji.map.colons[emojiKey]; | |
return replacement ? replaceWith : colonEmoji; | |
}); | |
} | |
TS.channels.onSendMsg = (function (original) { | |
return function (ok, msg) { | |
var channel; | |
if (ok) { | |
channel = TS.channels.getChannelById(msg.SENT_MSG.channel); | |
setTimeout(function () { | |
var newText = replaceText(msg.text, ':crab:'); | |
if (newText !== msg.text) { | |
TS.msg_edit.commitEdit(msg, channel, newText); | |
} | |
}, 2000); | |
} | |
return original.apply(this, arguments); | |
}; | |
}(TS.channels.onSendMsg)); | |
}()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Randomly selected replacements with: