我在这里真的很困惑。我想了解 chrome 扩展的文件架构。我正在阅读这篇文档:https://developer.chrome.com/extensions/overview#arch https://developer.chrome.com/extensions/overview#arch
我的情况:
我想设置 oauth 流程,以便用户可以在扩展内登录(另一个端点是我的 django 后端)。到目前为止,我有这些文件:
background.js
content.js
popup.html
manifest.json
我的 content.js 向 background.js 发送消息并获取响应。到目前为止还好!
但现在在阅读 oauth 文档时,我很困惑不知道 background.html 是什么。它实际上是应该包含我的background.js的所有js代码的文件吗?但是,如果我在清单中将其更改为.html
, like:
"background": {
"persistent": false,
"scripts": ["jquery111.js", "background.html"]
扩展不再工作。在 OAuth 文档中,它说:
Place the four library files in the root of your extension directory
(or wherever your JavaScript is stored). Then include the .js files in your
background page...
Your background page will manage the OAuth flow.
但在架构文档 https://developer.chrome.com/extensions/tut_oauth, 它说:
This figure shows the browser action's background page, which is defined by
background.html and has JavaScript code that controls the behavior of
the browser action in both windows.
background.html和background.js有什么区别?