バックグラウンドスクリプトからメッセージを取得するときに問題が発生します。私の心はほとんど吹き飛ばされました、間違いはどこにありますか?
マニフェスト
{
"name":"Some name",
"version":"0.1",
"manifest_version": 2,
"description":"extension for Google Chrome",
"permissions": ["tabs","http://*/*", "https://*/*", "<all_urls>","notifications","contextMenus","alarms","tabs","bookmarks"],
"content_scripts":[
{
"matches":["<all_urls>"],
"css":["style.css"],
"js":["content.js","jquery.js"]
}
],
"background": {
"scripts": ["background.js","jquery.js"],
"persistent": false
},
"icons":{
"16": "images/icon16.png",
"48": "images/icon48.png",
"128": "images/icon128.png"
},
"browser_action": {
"default_icon": {
"19": "images/icon19.png",
"38": "images/icon38.png"
},
"default_title": "Order Checker",
"default_popup": "popup.html"
}
}
background.js
chrome.tabs.getSelected(null, function(tab) {
console.log('Loaded!');
chrome.tabs.sendMessage(tab.id, {
greeting: "hello"
});
console.log('Sended on '+tab.id+'...');
});
content.js
chrome.extension.onMessage.addListener(function(msg, _, request) {
console.log('Getting request...');
console.log(msg.greeting);
});
バックグラウンドページで、予想どおり、コンソール2のメッセージが表示されます。しかし、コンテンツページにはメッセージがないので、content.jsのコードに問題があると思います。私が間違っているのは何ですか?