我正在编写一个Chrome扩展,它有一个content.js来操作当前选项卡数据以及执行时生成的弹出窗口。不过,我的问题是,当我对扩展进行更改时,我不得不重新加载扩展并刷新页面,否则会给我一个“建立连接时出错,端口不存在”的错误。这里是我的manifest.json文件Chrome扩展页面重新加载
{
"manifest_version": 2,
"name": "extension",
"version": "0.0",
"offline_enabled": true,
"content_scripts": [
{
"matches": [
"*://mail.google.com/*"
],
"css": ["css/jquery-ui.css"],
"js": ["js/jquery.js" , "js/jquery-ui.js" , "js/bootstrap.js" , "js/commons.js" , "js/content.js"],
"run_at": "document_end"
}
],
"browser_action": {
"default_title": "chrome",
"default_popup": "html/popup.html"
},
"permissions": [
"tabs",
"https://*.*.*/"
]
}
您是否有任何试图在线连接的content.js代码? – Meeh
我有一些API调用的网站是。那是什么导致了这个问题? –
从我对扩展的有限知识中,我认为这是你的问题。应将API调用移至background.js。 这是有人有类似的问题:http://stackoverflow.com/questions/13637715/not-receiving-any-data-from-webpage-to-content-js-of-chrome-extension 内容脚本应该用于与选项卡中的“当前”页面进行交互。像密码保护程序或开发/调试扩展程序,linter等。 https://developer.chrome.com/extensions/content_scripts – Meeh