I'm calling a function from my background.js in the extension.js but it seems it is executed several (three) times instead of once. From my console messages it looks like that the backgound only sends its message once, but the addListener executes three times. Any ideas to avoid this?
Background.js:
appAPI.tabs.getActive(function(tabInfo) {
console.log(1); // only once
tabUrl = tabInfo.tabUrl;
appAPI.message.toActiveTab({type:'clickedItem', url:tabUrl});
});
Extension.js:
appAPI.message.addListener(function(msg) {
if (msg.type === 'clickedItem') {
console.log(msg.url); // why three times?
}
});