drop this into the javascript console on a slack chat to have pastes automatically show up as preformatted text.
var TS_view_submit = TS.view.submit.bind(TS.view); TS.view.submit = function() { var msgInput = document.getElementById('message-input'); if (msgInput.value.indexOf('\n') > -1) msgInput.value = '```\n' + msgInput.value + '\n```'; return TS_view_submit.apply(this, arguments); }a more readable version
// store the original function
var TS_view_submit = TS.view.submit.bind(TS.view);
// hijack it
TS.view.submit = function() {
// get the input textarea
var msgInput = document.getElementById('message-input');
// if the input has a newline, make it preformatted
if (msgInput.value.indexOf('\n') > -1)
msgInput.value = '```\n' + msgInput.value + '\n```';
// call the original
return TS_view_submit.apply(this, arguments);
}
bookmarklet