0
所以我只是在每次点击扩展按钮时都想得到响应。因此,与类似的AdBlock如何归结每次点击扩展按钮时都无法播放响应
但是,相反,我只是试图做一个console.log()
每次单击该按钮没有任何明显的弹出窗口时间。
我已经试过这到目前为止
chrome.extension.onMessage.addListener(
function(request, sender, sendResponse) {
switch (request.directive) {
case "popup-click":
// execute the content script
chrome.tabs.executeScript(null, { // defaults to the current tab
file: "real.js", // script to inject into page and run in sandbox
allFrames: true // This injects script into iframes in the page and doesn't work before 4.0.266.0.
});
sendResponse({}); // sending back empty response to sender
break;
default:
// helps debug when request directive doesn't match
alert("Unmatched request of '" + request + "' from script to background.js from " + sender);
}
}
);
然后我real.js
console.log("Yo");
但遗憾的是我只能得到一个Yo
当它启动。有任何想法吗?
发送此消息您期望什么? – Xan 2014-12-06 22:46:07
它不是'功能(请求,发件人,sendResponse){'? @Xan – Idris 2014-12-09 01:16:28
这是听众。 – Xan 2014-12-09 01:17:26