Answer the question
In order to leave comments, you need to log in
Why is the alert repeated?
I can not understand why when you click on the icon again, which calls the code below
chrome.browserAction.onClicked.addListener(function(tab) {
chrome.tabs.executeScript({
file: 'sc.js'
});
chrome.tabs.query({url: "http://google.ru/*", currentWindow: true}, function(tabs) {
var port = chrome.tabs.connect(tabs[0].id, {name: "knockknock"});
port.postMessage({q: "ggh"});
})
});
chrome.runtime.onConnect.addListener(function(port) {
port.onMessage.addListener(function(msg) {
alert(msg.q)
})
});
Answer the question
In order to leave comments, you need to log in
Try wrapping the calls in a condition:if (window.top !== window.self)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question