我的清单:
{
"name":"name",
"version":"0.1",
"manifest_version":2,
"description":"name app",
"background":{
"scripts":[
"scripts/modernizr.min.js",
"scripts/background.js"
],
"persistent": false
},
"content_scripts": [
{
"matches": ["https://*/*", "http://*/*"],
"js": ["scripts/content.js"],
"run_at": "document_end"
}
],
"permissions":[
"contextMenus",
"tabs",
"http://*/*",
"https://*/*"
],
"icons":{
"16":"images/icon_16.png",
"128":"images/icon_128.png"
}
}
Background.js 有一个函数叫做:
chrome.contextMenus.onClicked.addListener( function( info, tab )
{
... stuff ...
chrome.tabs.sendMessage( tab.id, { action: "showLibraryUI", library: library }, function( response ){} );
} );
在 content.js 我有一个监听的函数,但它从未被调用:
chrome.runtime.onMessage.addListener( function( request, sender, sendResponse )
{
...stuff...
} );
在 _generated_background_page.html 的扩展中,我看到了这个:
端口:无法建立连接。接收端不存在。lastError:29 设置 lastError:29 dispatchOnDisconnect miscellaneous_bindings:259
我在 SO 上的其他帖子中找不到清单 > 2.0 的解决方案。