[英]Chrome extension using a background page + content scripts
我无法绕过Chrome扩展程序的结构。
我的扩展程序有两个不同的部分:
它使用后台页面通过oAuth登录,然后从oAuth整理大量数据并将其保存到chrome.storage.local
。
浏览网页时,它将调用chrome.storage.local
以检查当前域是否与从oAuth存储的信息匹配,如果匹配,则使用[Rich Notifications API][1]
显示通知。
我manifest.json
的结构很糟糕。
{
"name": "API Test",
"version": "3.1.2",
"manifest_version": 2,
"minimum_chrome_version": "29",
"app": {
"background": {
"scripts": ["main.js"]
}
},
"permissions": ["identity", "storage", "*://*/*"],
"oauth2": {
"client_id": "<<client_id>>",
"scopes": [
"https://www.googleapis.com/auth/plus.login",
"https://www.google.com/m8/feeds",
"https://www.googleapis.com/auth/contacts.readonly"
]
},
"content_scripts": [
{
"matches": ["*://*/*"],
"js": ["domchecker.js"]
}
]
}
这样做时,我从Chrome收到以下错误:
There were warnings when trying to install this extension:
'content_scripts' is only allowed for extensions and
legacy packaged apps, but this is a packaged app.
是否可以同时进行这两个过程? 如果没有,如何使用后台页面检查页面刷新并运行脚本?
您的清单是应用清单,如错误提示所提示。
要修复,请删除app
“包装”,它应该只是background.scripts
键。 然后它将是有效的扩展清单。
注意: chrome.notifications
不可用于内容脚本; 您将需要使用“ 消息传递”来请求背景页面进行显示。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.