简体   繁体   中英

How to programmatically send messages in HipChat?

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM