Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ajax call not working chrome extension with manifest v2

I'm trying to play around with a basic chrome extension which goes something like this

chrome.omnibox.onInputChanged.addListener(function(text, suggest){
       var baseUrl = "http://sample.com";
       var finalResult = [];
              $.ajax({
                     url : baseUrl,
                     dataType : "jsonp",
                     success: function(result) {
                                     for (var i=0; i<result[1].legnth; i++){
                                          finalResult.push(
                                                 {content : result[1][i], description : result[1][i]}
                                          );
                                     }
                                     suggest(finalResult);
                              },
                     async: false
              });           
});

This works with manifest version 1, but when I change it to v2, I'm getting the following error. I'd appreciate any help :)

Refused to load the script 'http://sample.com' because it violates the following Content Security Policy directive: "script-src 'self' chrome-extension-resource:".

like image 830
iman453 Avatar asked Aug 05 '12 22:08

iman453


1 Answers

You should read about Content Security Policy

complete your manifest file with:

    "content_security_policy": "script-src 'self' http://sample.com; object-src 'self'",
like image 182
Skalár Wag Avatar answered Sep 19 '22 14:09

Skalár Wag