A bit of a novice attempting to create my first Chrome extension here. I've verified my JQuery and html code to be working by running it via opening it in a browser in a normal .html file that calls the .JS file.
However, the Chrome extension with the same code fails to run, seemingly due to CSP issues. (I am calling the ajax library in my html via https)
Refused to load the script
'http://www.reddit.com/r/abandonedporn/.json?jsonp=jQuery111307901595502626151_1438751974832&_=1438751974833'
because it violates the following Content Security Policy directive:
"script-src'self' https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js". send @ library.js:5
I've modified my manifest.json file with every last thing that I thought necessary, including:
{"content_security_policy": "script-src 'self' https://ajax.googleapis.com/*; object-src 'self'"},
"permissions": [
"http://www.reddit.com/r/abandonedporn/.json?jsonp=?",
"http://www.reddit.com/*", "https://www.reddit.com/*",
"http://www.reddit.com/r/abandonedporn/",
"https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js/",
"http://www.reddit.com/r/abandonedporn/.json?jsonp=jQuery111309090442832093686_1438671168851&_=1438671168852",
"http://*/*", "https://*/*",
"http://reddit.com/json*",
"http://www.reddit.com/r/abandonedporn/*"],
and
"content_scripts": [
{
"matches": [
"https://www.google.com/*",
"http://www.reddit.com/abandonedporn/*"
],
"js": [
"src/inject/inject.js",
"src/content.js",
"src/override/get_pics.js",
"src/override/get_pics2.js",
"src/override/library.js"
]
}
]
}
Lastly, my actual Jquery script: (Note that changing ".getJSON" to ".getScript" did not help.)
document.addEventListener('DOMContentLoaded', function () {
$.getJSON("http://www.reddit.com/r/abandonedporn/.json?jsonp=?", function(data) {
$.each(data.data.children, function(i,item){
$("<img/>").attr("src", item.data.url).appendTo("#images");
});
});
});