Skip to content

Instantly share code, notes, and snippets.

@taross-f
Created October 31, 2016 05:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save taross-f/65763cec5c90fe0e7a2c4dba83781363 to your computer and use it in GitHub Desktop.
Save taross-f/65763cec5c90fe0e7a2c4dba83781363 to your computer and use it in GitHub Desktop.
add Re: buttons and quote buttons to hipchat
$(function(){
console.log("loding...");
setInterval(function() {
var buttons = $(".msg-line > .hc-dropdown");
buttons.each(function(_, element) {
var b = $(element);
if (b.children('.btn-addon').length) return;
// add quote button
var quoteButton = $("<button class='btn-addon'>quote</button>");
quoteButton.bind("click", function () {
setTimeout(function() { // react側でゴニョゴニョやってるので遅らせる
$("#hc-message-input").val("/quote " + b.next('.msg-line').text());
}, 100);
});
b.append(quoteButton);
// add Re: button
var reButton = $("<button class='btn-addon'>Re:</button>");
reButton.bind("click", function () {
setTimeout(function() {
$("#hc-message-input").val("Re: " + b.parents('.hc-chat-msg').children('.sender-name').text() + " ");
}, 10);
});
b.append(reButton);
}, this);
$("#hc-message-input").focus();
}, 5000);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment