来自Chrome扩展程序的HTTPS Ajax请求无效

时间:2013-03-21 22:13:08

标签: google-chrome-extension

我有一个chrome扩展程序,可以下载使用HTTPS的Hacker News的RSS源。自从我升级到Chrome扩展程序清单的最新版本后,我无法让它工作。 ajax请求失败,没有任何解释。

我99%确定我的javascript代码提出请求是正确的,所以我认为这是一个权限问题。

以下是我的清单中的权限和内容安全策略部分:

  "permissions": [
    "tabs",
    "https://news.ycombinator.com/",
    "http://news.ycombinator.com/",
    "notifications"
  ],
  "content_security_policy": "script-src 'self' 'unsafe-eval' https://news.ycombinator.com; object-src 'self' 'unsafe-eval' https://news.ycombinator.com"

有什么想法吗?

谢谢!


编辑:

这是Github Repo的链接:https://github.com/adamalbrecht/hacker-news-for-chrome/

2 个答案:

答案 0 :(得分:1)

我认为您应该"permissions": [ "tabs", "https://news.ycombinator.com/*", "http://news.ycombinator.com/*", "notifications" ],,因为Chrome需要一种允许的主机模式。请参阅this

答案 1 :(得分:0)

它适用于Chrome 27.0.1438.8,但您没有发布代码,因此要比较结果并不容易。这是我做的:

  1. 从Chrome小猫示例扩展程序开始。
  2. 将清单权限更改为...

    “权限”:[   “https://news.ycombinator.com/rss” ]

  3. 在popup.js中,将searchOnFlickr_更改为相同的网址。

  4. 将showPhotos_更改为log e.target。
  5. 然后我加载了扩展,右键单击了浏览器动作弹出窗口,并检查了该元素。在日志中,我在responseText中看到了预期的RSS内容。

相关问题