简体   繁体   English

如何使用chrome扩展程序打包JSON文件?

[英]How can I package JSON files with my chrome extension?

I have created an extension containing a pre-existing javascript file. 我创建了一个扩展,其中包含一个预先存在的javascript文件。 This javascript file requires a json config file in the same directory, but putting that file in the same directory in the extension folder didn't work. 此javascript文件在同一目录中需要一个json配置文件,但是将该文件放在扩展文件夹的同一目录中是行不通的。 Is there some special way I have to do this? 我必须有一些特殊的方法吗?

This problem also proved IMPOSSIBLE to Google since all extensions needs a json manifest file. 由于所有扩展名都需要一个json清单文件,因此该问题对Google也是不可能的。

Try adding it in the content_scripts section of the manifest.json . 尝试将其添加到manifest.jsoncontent_scripts部分中。

  "content_scripts": [
    {
      "matches": ["https://*/*", "http://*/*"],
      "js": ["extension.js", "config.json"],
      "run_at": "document_start",
      "all_frames": true
    }
  ],

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM