Skip to content

Instantly share code, notes, and snippets.

@Sheile
Last active December 2, 2015 09:47
Show Gist options
  • Save Sheile/56834fb8e76fbb54ae11 to your computer and use it in GitHub Desktop.
Save Sheile/56834fb8e76fbb54ae11 to your computer and use it in GitHub Desktop.
Greasemonkey script for inline code block on slack
// ==UserScript==
// @name Insert space before backquote
// @namespace net.sheile.dev.slack-backquote
// @include https://*.slack.com/*
// @version 1
// @grant none
// ==/UserScript==
(function() {
$('#message-input').bind('keydown', function(e) {
if(e.keyCode == 13 && !e.shiftKey) {
var message = $(this).val();
message = message.replace(/(^|.)(`([^`\r\n]+?)`)/g, function(match, pre, entire) {
if(pre.match(/^$|[\s,.!"#$%&(-={?:;<>^\[]/)) return match;
return pre + ' ' + entire;
});
$(this).val(message);
}
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment