Problem with firefox add-on on site that does not refresh / browse Ajax / JS

0

I'm developing my first Webextension (Firefox add-on) and it's working properly.

However, I'm having problems when part of the site is navigated without refresh. That is, the extension does not work because it only works when you refresh or finish the page request.

My code is pretty much this:

node = document.getElementsByClassName("exemplo")[0];
if (node.parentNode) {
  node.parentNode.removeChild(node);
}

I do not know if there is any way or function to make the site call this code whenever it changes its status even though it does not make a new request.

    
asked by anonymous 31.01.2017 / 22:07

1 answer

0

I was able to find the answer!

Just use this function, passing this parameter:

document.addEventListener('DOMNodeInserted', function (event) {
   seuscodigos();
});

Because the document.addEventListener (); function adds listeners in the DOM of the site and passing the 'DOMNodeInserted' parameter every time a node is inserted into the page, the code you enter inside the function will be executed.

NOTE: I do not know how to check that my own question has been answered.

    
02.02.2017 / 13:42