【问题标题】:Chrome extension manifest error: content_script[0].matches[0]Chrome 扩展清单错误:content_script[0].matches[0]
【发布时间】:2012-11-17 11:57:45
【问题描述】:

我相信这可能是问题所在:

"content_scripts" : [
    {
      "matches" : [
        "http://195.88.55.16"
      ],
      "js" : ["script.js"],
      "run_at" : "document_idle",
      "all_frames" : false
    }

【问题讨论】:

    标签: google-chrome google-chrome-extension content-script


    【解决方案1】:

    您需要在 matches 部分的主机上附加一个斜杠(可能是斜杠 + 星号),以使该模式有效。

      "matches" : [
        "http://195.88.55.16/*"
      ],
    

    有关更多信息,请查看match patterns 的文档:

    这是基本语法:

    <url-pattern> := <scheme>://<host><path>
    <scheme> := '*' | 'http' | 'https' | 'file' | 'ftp' | 'chrome-extension'
    <host> := '*' | '*.' <any char except '/' and '*'>+
    <path> := '/' <any chars>
    

    【讨论】:

    • 谢谢,我想这会奏效。我唯一的想法是,这将使它对站点的所有子页面都有效,而我希望它只在首页运行。不过问题不大。
    • 对于首页,省略尾随星号;只需使用斜线。
    • "http://195.88.55.16" 不好。 "http://195.88.55.16/" 仅适用于首页。 "http://195.88.55.16/*"good 并在所有子页面上触发。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-06-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-09-19
    • 2012-08-02
    相关资源
    最近更新 更多