# SE Chat Modifications — Keyboard navigation and commands for chat

## Screenshot

Use /command shortcuts to perform common chat tasks:

See message history inline:

Easily preview replied-to messages:

And much, much more...

Legends tell of a prolific Meta Stack Overflow chatter who despised using their mouse above all things. In an effort to keep their hands firmly on the keyboard, this chatter set out to make a userscript that would bring all of chat's functionality within a few keystrokes' reach.

To make this possible, the userscript provides the following features:

• /command shortcuts to perform many different chat tasks, such as starring, flagging, and loading older messages, as well as some non-native chat tasks, like Vimeo pseudo-oneboxes and in-chat note taking
• Keyboard navigation to select and take action on specific messages without ever having to reach for the mouse
• Extensible interface for writing custom commands, key bindings, and pseudo-onebox generators in your own userscripts

The script makes use of the livequery plugin and therefore must be used in a way consistent with that plugin's dual MIT/GPLv2 license.

### Platform

The script should work under all major userscript-supporting browsers. Please file a bug if you encounter any issues.

## Contact

Rebecca Chernoff *, Yi Jiang, and Tim Stone actively maintain this script, with additional code contributions from Benjol and Michael Mrozek.

Feedback can be given on GitHub, or by "@lerting" one of the maintainers on Meta Stack Overflow chat.
*This script is in no way associated with Stack Exchange Inc.

## Code

In addition to forking the GitHub repository, you can write your own userscripts that leverage this script's functionality by using the ChatExtension object.

For example, you can create new /command actions:

// Will be called on /myCommand
ChatExtension.define('myCommand', function () {
console.log("This is my own command");

return ChatExtension.CommandState.SucceedDoClear;
});


Or, you may want to add in support for a custom pseudo-onebox, like the one for Vimeo that comes built-in:

// Will be called on /ob vimeo.com/path
ChatExtension.associate('vimeo.com', function (domain, path) {
// Perform Vimeo pseudo-onebox magic by calling the Vimeo API
// and submitting messages on behalf of the users
});


To learn more, check the source code, or explore the ChatExtension object in your developer console of choice. Additional documentation will hopefully be made available in the near future.

-
I LOVE THIS USERSCRIPT!!!! –  Josh Feb 21 '11 at 21:20
+1 Needs more jQuery :) –  Nathan Osman Feb 22 '11 at 3:04
Quick question... when you define a custom command, is there a way for it to receive arguments? For example: '/dosomething arg1 arg2' ? –  Nathan Osman Feb 23 '11 at 1:27
@GeorgeEdison Your function will be called so that arguments will be everything after the command, broken up at whitespace. So you can get arg1 via arguments[0], and so on. For cases where you want everything after the command as a single string, we current do \$.makeArray(arguments).join(' '). –  Tim Stone Feb 23 '11 at 2:39
Hmm, these commands really need some kind of builtin description mechanism... thinks... –  Benjol Feb 24 '11 at 10:51
@Ben: What you need is: /help –  Nathan Osman Feb 27 '11 at 3:59
@George, I know about that :) What I mean is that there should be not just a list of commands, but that /help command should show some more information. I'm (sort of) working on it... –  Benjol Feb 27 '11 at 9:47
@Benjol: Sounds good! –  Nathan Osman Feb 27 '11 at 19:39
There's now pseudo-onebox support for Stack Exchange comments through the /ob command. To easily get URLs for comment oneboxing, please see the SE Modifications script. –  Tim Stone May 7 '11 at 3:04
Note: Chat upgraded from jQuery 1.4 -> 1.5, which caused several things to unexpectedly break. Updating the script to the latest version will resolve these problems. –  Tim Stone Oct 21 '11 at 17:35
Updates to chat today broke this script. –  NullUserException Dec 22 '11 at 18:15
@NullUserException Updating to the latest should fix the issue for the moment. –  Tim Stone Dec 22 '11 at 18:42
Any way this could be a browser extension? (The benefit would be that the browser could be set to search for updates automatically.) –  msh210 Mar 18 '13 at 4:09
@msh210 Yeah, we had considered that before, we just never quite got around to looking into it. I'll make a note and see what I can do, though. –  Tim Stone Mar 18 '13 at 4:13
@durron597 Yeah, that's an unfortunate and terrible policy they've taken on. You can use TamperMonkey to work around it, but I'll consider turning this into an actual extension so it can be posted on the Chrome Web Store. –  Tim Stone Jul 7 '14 at 15:49

2 ideas for drastically simplifying some command inputs:

A bare command such as /edit or /delete should assume "the last message I sent". Note that it will not necessarily be the highest id, because that could be one of another user.

Alternatively, if that implementation is too hard, avoiding the id number when the intent is obvious is still a nice idea, so perhaps instead of a bare command, something such as /edit last or /edit -1 could be used to indicate "my last message".

-
This makes sense, I'll put it on my to-do list. Note that using the Up Arrow in the input box will already allow you to edit your most recent message (this is native chat functionality). –  Tim Stone May 26 '11 at 22:25
Holy cow I did not know that... Thanks! Not that I need to argue my point further, but I'd say to that: There should still be an easy way to delete the last message, which is not accomplished by editing the last message and deleting the entire text of the message. So if you implement /delete -1, I would highly suggest /edit -1 for consistency. –  VxJasonxV May 26 '11 at 23:23
This was actually such a good idea that we had already done it, but there was a bug later on that was preventing it from allowing an undefined parameter through. ;) In any case, /del and /edit with nothing after them should both work for your most recent message now after updating. –  Tim Stone May 29 '11 at 3:52
The only good response to that is; You know what they say about great minds... –  VxJasonxV May 29 '11 at 4:46

I think there is a bug: I was trying out the Clipboard feature, but I don't seem to be able to Delete/Paste items from the clipboard. If I try to delete an item, it always comes back if I click again on the "clipboard" button. and if I click Paste, nothing happens.

I'm using Firefox 27.0.1 and Windows 7.

In case it matters: I installed the following add-ons:

-

I to remember reporting this before and the problem being solved, but it's back:

When I navigate through messages with CTRL+UP/DOWN, message by ignored users are silently traversed.

-
Hm, I can't reproduce this. Are you sure you're running the latest? –  Tim Stone Jun 5 '14 at 2:31
@TimStone There is no version number in the script but Greasemonkey's "Update" does not do anything, so yea, I guess. –  Raphael Jun 5 '14 at 6:43
@TimStone Anyway, can't reproduce it now so maybe it was a temporary change in chat, or I don't know what. Thanks for checking! –  Raphael Jun 5 '14 at 6:44