Mahmoud M. Abdel-Fattah
Mahmoud M. Abdel-Fattah

Reputation: 1527

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

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

Upvotes: 6

Views: 873

Answers (1)

abraham
abraham

Reputation: 47873

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.

Upvotes: 3

Related Questions