0
votes

I have problems with including ga.js in my extension. Please, help. My code:

manifest included

"content_security_policy": "script-src 'self' https://ssl.google-analytics.com; object-src 'self'"

analytics.js

var _AnalyticsCode = 'UA-XXX';//instead XXX my number

var _gaq = _gaq || [];
_gaq.push(['_setAccount', _AnalyticsCode]);
_gaq.push(['_trackPageview']);

(function () {
    var ga = document.createElement('script');
    ga.type = 'text/javascript';
    ga.async = true;
    ga.src = 'https://ssl.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0];
    s.parentNode.insertBefore(ga, s);
})();

This script added in 2 page - popup.html and options.html. On popup all right, but options page says:

Refused to load the script 'data:application/javascript;base64,dmFyIHVyY2hpblRyYWNrZXI9ZnVuY3Rpb24oKXt9…JVcmw6ZnVuY3Rpb24obyl7cmV0dXJuIG87fSxfdHJhY2tFdmVudDpmdW5jdGlvbigpe319fX07' because it violates the following Content Security Policy directive: "script-src 'self' https://ssl.google-analytics.com".

1

1 Answers

9
votes

Hmm, this problem was releted with using Ghostery extension - it blocks analysts scripts, replacing them with a stub. Naturally, the stub script does not satisfy the content security policy conditions.

Perhaps the answer will be useful to someone