Gdy próbuje komunikować się między moim Script Content i tła uzyskać następujące błędy:Rozszerzenie Chrome: błąd portu: nie można nawiązać połączenia. Odbieranie końca nie istnieje.
Port error: Could not establish connection. Receiving end does not exist.
Error in event handler for 'undefined': Cannot read property 'message' of undefined
TypeError: Cannot read property 'message' of undefined
background.js
function onRequest(request, sender, callbackFunction) {
console.log("Me (BS) became this Message:" + request.message);
sendResponse({message: request.message})
};
chrome.extension.onRequest.addListener(onRequest);
streamcloud.js
function contactBackground(nachricht){
chrome.extension.sendMessage({message: nachricht}, function(response) {
console.log("The Background Script got the following Message: " + response.message);
});
}
i mój plik manifest.jso n
{
"name": "InstantWatch - Dev",
"manifest_version": 2,
"version": "0.7",
"permissions": ["tabs", "http://*/", "https://*/"],
"background": {
"scripts": ["background.js"]
},
"browser_action": {
"default_title": "InstantWatch",
"default_icon" : "icon.ico"
},
"content_scripts": [
{
"matches": ["http://*/*", "http://*/*"],
"js": ["jquery.js", "streamcloud.js"]
}
]
}
mogę znaleźć rozwiązanie dodać BACKGROUND_PAGE: „background.html” pustym background.html, ale ponieważ nie jest obsługiwany BACKGROUND_PAGE od manifest_version 2, nie można jej użyć.
Innym sposobem, który rozwiąże mój problem z dokładnie tego samego błędu: http://stackoverflow.com/a/13565529/390747 – WooCaSh