Last active
December 2, 2015 09:47
-
-
Save Sheile/56834fb8e76fbb54ae11 to your computer and use it in GitHub Desktop.
Greasemonkey script for inline code block on slack
This file contains 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
// ==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