Reputation: 300
My task is only to write a bookmarklet for simplifying editing messages in HipChat in my team. I wrote the following:
var id = document.querySelector('.hc-dropdown-trigger.aui-dropdown2-trigger.aui-button.aui-button-subtle.aui-dropdown2-trigger-arrowless.active.aui-dropdown2-active').id.slice(16, -8),
msg = document.querySelector('[data-mid="' + id + '"]').innerText,
evt = document.createEvent('KeyboardEvent'),
edit = prompt(msg, msg);
if ( edit !== null ) {
document.getElementById('hc-message-input').value = 's/' + msg + '/' + edit;
evt.initKeyEvent('keydown', true, true, window, false, false, false, false, 13, 0);
document.body.dispatchEvent(evt); // also tried dispatch on textearea itself
}
But nothing happens. How can I achive my goal?
Thanks a lot.
Upvotes: 1
Views: 187
Reputation: 3923
APIs exist so you don't have to do all this by hand. The HipChat API documentation is found at: https://www.hipchat.com/docs/apiv2
To send a message, take a look at https://www.hipchat.com/docs/apiv2/method/send_message
Upvotes: 3