Reputation: 2747
I want a script running on my browser action popup to get information from the current active tab when invoked. It's not clear to me how to communicate between the two. Do I need a content script running on the active tab and a chrome.tabs.sendMessage()
requesting info from it? What permissions should I ask for?
Upvotes: 0
Views: 512
Reputation: 302
Yes, the communication between content-script and other scripts (background, browserAction, pageAction) goes via messages. So, on each side you have this kind of code:
chrome.runtime.onConnect.addListener(function(port) {
port.onMessage.addListener(function(request) {
// process the request
// reply as port.postMessage(data) if needed
};
};
Upvotes: 1