I'm making a google chrome extension to give the specific information (via ajax with server side) for different url (tab).
I use chrome.tabs.onUpdated
and chrome.tabs.onActivated
event listener in background.js
to detect whether the url of the active tab is changed, and then send an ajax request to change the icon using chrome.browserAction.setIcon
. (Yes, I would like to use browser action instead of page action because I wanna show some overall information of the extension in popup page, like Adblock Plus does)
However, what I can't figure out is:
- How could I communicate between the background and the popup page? I understand that I should use
chrome.tabs.sendMessage()
andchrome.runtime.onMessage
to communicate between background and the content scripts, but how could I communicate between the former and the popup script? I can't see that I need content scripts to modify the content of the page. - How to "store" the information I already get, in the popup page of each page so that I don't need to send few more requests, when the user change the activated tab but the url is not changed?
Any idea? Thanks in advance!