google-chrome-extension - Google Chrome 扩展程序中的多个后台脚本?

标签 google-chrome-extension

我的任务是创建一个 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/

相关文章:

javascript - 在我的 chrome 扩展的其他选项卡中注入(inject)脚本时出错

jquery - 使用 declarativeContent 权限,使用 jQuery 内容更改后隐藏 pageAction

javascript - Chrome Cookie API 不允许我使用返回值

javascript - 未捕获的类型错误 : Failed to construct 'URL' : Invalid URL in chrome extension v3 when using messages

javascript - 从 3xx : Redirection HTTP response with Web Extension 获取重定向位置 (URL)

google-chrome - 在 chrome 扩展中禁用 "inspect popup"菜单项

javascript - 查询本地存储条目而不抛出错误

javascript - 如何加载/构建 Chrome 应用程序/扩展程序并以编程方式运行

javascript - 点击事件在 Chrome 扩展程序的后台页面中不起作用

javascript - jQuery 不从 outlook.com 中删除元素