I am just starting writing chrome extension.
I need an advice on what should I use for this extension: content script with background page or just a background page.
This is what extension does (I just choose this requirements for my first extension)
Runs only on news.google.com
Finds news blocks that have certain “sources” of news, for example “USA Today” and then sets lightblue background on all divs that have this source.
I already wrote a content script for this using jquery, which is super easy.
But now I want to also set a pageAction icon if any of my “sources” were found on the page, also I would like to add listener for that content button that would toggle the highlighting of my found sources on and off.
I discovered that this cannot be done from content script.
So now I have a dilemma: should I rewrite my extension to use only background page OR keep content script and use message passing to pass message to background page if any sources were found, then have script in background page set the pageAction, add listener for it?
I am looking for advice from someone who has real world experience with these things.
You have to use both. background_page can’t access the content of tabs and content_scripts can’t create/listen to pageActions.