function sendMessage(message){ const mainEl = document.querySelector('#main') const textareaEl = mainEl.querySelector('div[contenteditable="true"]') if(!textareaEl) { throw new Error('There is no opened conversation') } textareaEl.focus() document.execCommand('insertText', false, message) textareaEl.dispatchEvent(new Event('change', { bubbles: true })) setTimeout(() => { (mainEl.querySelector('[data-testid="send"]') || mainEl.querySelector('[data-icon="send"]')).click() }, 100) }