How to load Google Analytics and Facebook SDK in chrome extension?

风流意气都作罢 提交于 2020-01-14 09:52:09

问题


I'm developing a chrome extension using Kango framework, and I waned to use both Google Analytics and facebook SDK. I edited the manifest file to include the follwoign

"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"

But it doesn't work! and I'm getting the following error

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".

回答1:


Change the script-src directive to have 'unsafe-eval' at the end.

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

Note that this will lower the security of your extension as random strings of JavaScript can be executed.



来源:https://stackoverflow.com/questions/20645651/how-to-load-google-analytics-and-facebook-sdk-in-chrome-extension

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!