【问题标题】:Google Chrome - uploading apps to chrome web store but how to allow all domain with manifest.json?Google Chrome - 将应用程序上传到 chrome 网上商店,但如何允许所有域使用 manifest.json?
【发布时间】:2014-11-06 08:34:40
【问题描述】:

我已经准备好带有 zip 文件的 Chrome 网上商店包。但问题是 manifest.json 我需要允许两个域 + 所有子域。

这是参考:

https://developer.chrome.com/extensions/manifest https://developer.chrome.com/extensions/content_scripts

它的说法是:“匹配”:[“http://www.google.com/*”] 但是我怎么说在匹配中允许两个域与所有子域?示例:

*.stackoverflow.com 和 *.centos.org?

{
  "name": "My extension",
  ...
  "content_scripts": [
    {
      "matches": ["http://www.google.com/*"],
      "css": ["mystyles.css"],
      "js": ["jquery.js", "myscript.js"]
    }
  ],
  ...
}

【问题讨论】:

    标签: google-chrome google-chrome-extension manifest google-chrome-app chrome-web-store


    【解决方案1】:

    您正在查看文档的错误部分。

    Match Patterns
    Match patterns and globs

    注意"matches" 属性是一个数组。

      "content_scripts": [
        {
          "matches": ["*://*.stackoverflow.com/*", "*://*.centos.org/*"],
          "css": ["mystyles.css"],
          "js": ["jquery.js", "myscript.js"]
        }
      ],
    

    以上内容将匹配stackoverflow.comcentos.org 及其所有子域上的所有页面。需要注意的是,只会匹配 stackoverflow.com
    * 代替 http 将完全匹配 httphttps

    【讨论】:

    • 我仍然得到这个: GET chrome-extension://xxxxx/icon.png net::ERR_FAILED chrome-extension://xxxx/icon.png:1 { "constraintName": "" , "消息": "", "名称": "InvalidStateError" }
    • 得到这个在哪里?我看不出它与这个问题有什么关系。如果您还有其他问题,请提出其他问题。
    • 在我的 Javascript 控制台中,当我启动应用程序并执行应用程序时,控制台中出现此错误。就像你提到的那样,我已经应用了我的 zip 文件。
    • 这与您的原始问题有什么关系?
    猜你喜欢
    • 1970-01-01
    • 2014-07-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-09-02
    • 1970-01-01
    相关资源
    最近更新 更多