无法在Chrome扩展程序中运行内容脚本

时间:2018-07-17 20:13:48

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

我已经编写了用于编写Google chrome扩展程序的代码,但是问题是我无法在chrome控制台中执行内容脚本。 这是我的以下代码

对于清单文件:-

    {
      "manifest_version": 2,

      "name": "My new extension",
      "description": "It does stuff",
      "version": "1"
      "content_scripts": [
    {
       "matches": ["<all_urls>"],
       "js": ["content.js"]
     }
   ]
 }

对于我的内容脚本:-

     console.log("Hello world!");

当我部署扩展程序时,它被正确接受。它应该在chrome控制台上打印,但是当我刷新时,什么也没打印。 谁能帮助我哪里做错了? 预先感谢。

1 个答案:

答案 0 :(得分:1)

要注入内容脚本,您需要至少在清单中添加以下权限:

getParkingSpots(date) {
  const gmtCall = this.http.get(url1+date+"GMT");
  const nonGmtCall = this.http.get(url2+date);

  return this.getFuseauHoraire().pipe(
    concatMap(data => data=="GMT" ? gmtCall : nonGmtCall)
  );
}

检查documentation

相关问题