rfmacedo / IntercomEnterSending

// ==UserScript==
// @name         IntercomEnterSending
// @namespace    http://tampermonkey.net/
// @version      1.1
// @description  Send intercom message just adding a white space
//               at the end of the line and pressing enter
// @author       Rafael Macedo
// @match        https://app.intercom.io/*
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    function verify(){
        $('.composer-inbox').bind("DOMSubtreeModified",function(){
            if($(this).html().includes(' <br></p>')){
                var buttonFather = $('#'+this.id).parent().parent().parent().parent().next();
                $('#'+buttonFather.attr('id')+' button.btn.o__primary.ember-view').click();
            }
        });
        setTimeout(verify, 300);
    }
    verify();
})();