0

I have two questions, first question: why is browser action fired when I open the browser or open a new tab(not only when I click)? Another question is: my extestion changes all website colors, but when the website gets more information (such as facebook) after the browser action is fired, this can not be changed?
what can I do to make the browser action always change all the news too?

my background.js is:

chrome.browserAction.onClicked.addListener(function(tab) {  
  chrome.tabs.executeScript({
    file:"content.js"
  });
});

and my content.js starts with:

$(document).ready(function(){
        hauptProg();
        });
user3625605
  • 323
  • 1
  • 5
  • 16

1 Answers1

1

The answer on your second (and main) question depends ... on how the destination page has been implemented. There is no general answer, only a few suggestions

  • You can work with MutationObserver to find out when the content of the elements has changed. You could then execute your code again
  • Maybe you can see that, let's say, two seconds after page load the additional content has been loaded. Then you could start a timeout with window.setTimeout(yourMethod, 2000) to executed your method after 2 secs
devnull69
  • 16,402
  • 8
  • 50
  • 61
  • the second suggestino can I not do, for example on facebook, the news can after 4 minutes or more i try the first – user3625605 May 14 '14 at 10:40
  • `DOMSubtreeModified` is deprecated. The modern way to do this is with DOM MutationObserver. See my answer [here](http://stackoverflow.com/questions/23623399/getting-dom-object-fails-with-jquery-in-content-script/23625023#23625023) for an example. – Xan May 14 '14 at 12:30