I'm trying to manipulate GMail DOM with angularjs into a chrome extension.
For the moment I have a basic app :
(function() { "use strict";
  var html = document.querySelector('html');
  html.classList.add('gmail-detect-response');
  angular.bootstrap(html, ['myGmailApp']);
  html.classList.add('ng-app');
  html.classList.add('ng-csp');
}());
And a directive :
(function(){ 'use strict';
  angular.module('myGmailApp').directive('gmailDetectResponse', detectResponse);
  function detectResponse(){
    return {
      restrict: 'A',
      link: function(scope, element, attrs){
        var target = document.body;
        var config = {
          attributes: true,
          childList: true,
          subtree: true
        };
        var observer = new MutationObserver(function(mutations){
          mutations.forEach(function(mutation){
            if(mutation.addedNodes.length > 0){
              console.log('mutmut');
              var responseDivs = document.getElementsByClassName("gH acX");
              for(var i = 0; i < responseDivs.length; i++){
                if(responseDivs[i].getAttribute('gTrelloSend') == null){
                  responseDivs[i].setAttribute('gTrelloSend', '');
                  var para = document.createElement('p');
                  var textNode = document.createTextNode('TEST');
                  para.appendChild(textNode);
                  responseDivs[i].insertBefore(para, responseDivs[i].firstElementChild);
                }
              }
            }
          });
        });
        observer.observe(target, config);
      }
    }
  };
})();
My mutation observer works fine if I put it in a basic js file. Why my directive isn't executed ?
My goal is to detect all "response divs" into Gmail in order to create a button who can call an angularjs controller.
Thanks a lot !
