Firefox 和 Chrome 之间的内容脚本差异:无法获取 API 数据

Content scripts difference between Firefox and Chrome: not able to get API data

我正在使用我的 chrome 扩展程序在 Arxiv.org 的 api 上获取数据。

以下代码在执行时有效:

如果有帮助,content_script.jshttps://arxiv.org/abs/1801.06146

上触发
// content_script.js
$.get(`https://export.arxiv.org/api/query`, { id_list: "1801.06146" })
    .done((data) => {
        console.log("done");
        console.log(data);
    })
    .fail((jqXHR, textStatus, errorThrown) => {
        console.log("fail");
        console.log({ jqXHR, textStatus, errorThrown });
    });

FF 故障看起来像:

// manifest.json
"permissions": [
    "https://arxiv.org/*",
    "https://proceedings.neurips.cc/*",
    "https://openaccess.thecvf.com/*",
    "tabs",
    "activeTab",
    "storage",
    "unlimitedStorage",
    "downloads"
  ],
  "content_scripts": [
    {
      "matches": [
        "*://arxiv.org/*",
        "*://*.arxiv-vanity.com/*",
        "*://proceedings.neurips.cc/*",
        "*://openaccess.thecvf.com/*"
      ],
      "run_at": "document_start",
      "js": [
        "src/shared/jquery.min.js",
        "src/shared/utils.min.js",
        "src/content_scripts/content_script.js"
      ],
      "css": [
        "src/content_scripts/downloadButton.css",
        "src/content_scripts/loader.css",
        "src/content_scripts/content_script.css"
      ]
    }
  ]

实际上错误不是很有用,但我想通了问题:将 "https://export.arxiv.org/*", 添加到清单的权限。

出于某种原因 (?) Chrome 允许 https://export.arxiv.org/api/... 声明 https://arxiv.org/* 而不是 Firefox