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