5

我正在使用Kango框架開發一個Chrome擴展,並且我放棄了同時使用Google Analytics和Facebook SDK。我編輯清單文件包括follwoign如何在Chrome擴展中加載Google Analytics和Facebook SDK?

"content_security_policy": "script-src 'self' https://ssl.google-analytics.com https://connect.facebook.net; object-src 'self'; default-src 'self' 'unsafe-eval' chrome-extension-resource: https://*.facebook.net https://*.facebook.com; style-src 'self' 'unsafe-inline' chrome-extension-resource: https://*.facebook.net https://*.facebook.com; frame-src 'self' 'unsafe-inline' chrome-extension-resource: https://*.facebook.net https://*.facebook.com" 

但它不工作!而且我發現了以下錯誤

Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "script-src 'self' https://ssl.google-analytics.com https://connect.facebook.net". 
+0

我想知道多少描述性的錯誤信息可能是。下一級可能是自我糾正錯誤... :) – gkalpak

回答

3

更改script-src指令有'unsafe-eval'結尾。

script-src 'self' https://ssl.google-analytics.com https://connect.facebook.net 'unsafe-eval'; 

請注意,這會降低擴展的安全性,因爲可以執行隨機的JavaScript字符串。

相關問題