Created
November 10, 2014 19:26
-
-
Save swalberg/0f6dc4f58bae6e653082 to your computer and use it in GitHub Desktop.
Post to HipChat from browser (default to highlighted text)
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
// Get your token from the HipChat website "API Access" menu | |
// Add the token and room where indicated in this line (we use "Easylog") | |
// Make a new page in your button bar with this in it: | |
javascript:(function(){function getSelectionText() { var text = "";if (window.getSelection) { text = window.getSelection().toString();} else if (document.selection && document.selection.type != "Control") {text = document.selection.createRange().text;} return text;} var auth_token = "MYTOKENGOESHERE";var room = "Easylog";var ajax = new XMLHttpRequest;var url = "https://api.hipchat.com/v2/room/" + encodeURIComponent(room) + "/notification?auth_token=" + auth_token;ajax.open('POST', url, true);ajax.setRequestHeader("Content-type", "application/json");var message = prompt('log entry?', getSelectionText()); if (message) {ajax.send('{"color":"green", "message": "' + message + '"}');} })() | |
// getSelectionText() copied from http://stackoverflow.com/questions/5379120/get-the-highlighted-selected-text |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
We have a HipChat room that we post changes to so that team mates can see what's going on. The code above implements a bookmarklet that prompts you for a message to send to the room from your browser. The default value for this prompt is the currently highlighted text on the screen, which makes copying issue descriptions or urls fairly easy.