我的任务是创建一个 Google Chrome 扩展程序。到目前为止,一切正常。但是,我希望能够使用多个后台脚本(我的意思是"background" : {"scripts" : ["background.js"]},
如果我说的不清楚)而不是创建多个扩展。这可能吗?
问候,
最佳答案
According to the documentation :
A background page will be generated by the extension system that includes each of the files listed in the scripts property.
所以是的,它应该工作。只需声明多个脚本:
...
"background": {
"scripts": [
"background.js",
"backgroundone.js",
"backgroundtwo.js"
]
},
...
所有这些脚本都可以像加载到同一页面一样工作;它们都将共享相同的上下文。
关于google-chrome-extension - Google Chrome 扩展程序中的多个后台脚本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22344885/