You can connect contentScript with the extension onLoad, onEvent or
whatever you want, also you can send the tab.id as parameter to the
ToolStrip to identify where is the contentScript.

See this example:

//$contentScript.js

port = chrome.extension.connect({name: 'portname'});
port.onMessage.addListener(onMessageRecieved);
port.postMessage({message: "givemesomething"});

function onMessageRecieved(data) {
        if (data.message == "something") {
                console.log("Toolstrip Say: "+data.something);
        }
}

//$ToolStrip.html

var myport;
chrome.extension.onConnect.addListener(onPortConnect);

function onPortConnect(port) {
        if(port.name != 'portname') return false;
        myport = port;
        port.onMessage.addListener(onMessageRecieved);
}

function onMessageRecieved(data) {
        if (data.message == "givemesomething") {
                console.log("contentScript Say: "+data.message);
                myport.postMessage({message: "something", something: "Now you 
have
something from ToolStrip"});
        }
}


-v1c1ous

On Sep 15, 7:48 pm, Anatoly Yakovenko <[email protected]> wrote:
> so if i add the tabs permissions to my extension i am able to post
> messages, but i am not receiving them in my content script.  anyone
> have any idea on what i need to do togetmy content script to
> "receive" messages.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Chromium-extensions" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/chromium-extensions?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to