Using jQuery in an overridden new tab in Chrome Extension violates content security policy?

I have a chrome extension where I override newtab with the html index.html file.
I want to use "index.html" in this. How can i do this? jQuery

Here is my simplified code:

manifest.json

{
    "name": "Test Name",
    "description": "Test Description",
    "version": "0.1",
    "chrome_url_overrides": {
        "newtab": "index.html"
    },
    "manifest_version": 2,
}


index.html

<html>
    <head>
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
        <script src="index.js"></script>
    </head>
    <body>
        <div> Hello World ! </div>
    </body>
</html>


index.js

console.log('Extension loaded successfully ...');
console.log($('div')); // console.log(jQuery('div'));


But I keep getting the following two errors in the console.

Refused to download the script ' https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js ' because it violates the following content security policy directive:' script -src 'self' chrome- extension-resource: ".

Extension successfully downloaded ...

Unprepared ReferenceError: $ undefined


UPDATE: 1 , :

"content_security_policy": "script-src 'self' https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js 'unsafe-eval'; object-src 'self'",


UPDATE: 2 , , :

"permissions": [ "http://*/", "https://*/" ]


?

+4
2

CSP. ( ):

"content_security_policy": "script-src 'self' https://ajax.googleapis.com 'unsafe-eval'; object-src 'self'"

, Chrome, CDN.

, , - .

+4

$( document ).ready() console.log, , DOM :

$(document).ready(function(){
    console.log($('div'));
})
+1

Source: https://habr.com/ru/post/1584242/


All Articles