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

Asked

Viewed 24 times

0

I am developing my first Webextension(Firefox Add-on) and is working properly.

However, I’m in trouble when part of the site is browsed without giving refresh. That is, the extension does not work because it only works when you refresh or finish the page request.

My code is practically that:

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

I don’t know if there is any way or function to make the site call this code whenever change its state even not making a new request.

1 answer

0

I was able to find the answer!

Just use this function by passing this parameter:

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

For the function Document.addeventlistener(); Add listeners to the DOM of the site and pass the parameter 'Domnodeinserted', every time some node is inserted into the page, the code you insert into the function will be executed.

NOTE: I don’t know how to mark that my own question has been answered.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.