0

My chrome extension is using content scripts on a https site. And in the javascript, it works fine if I try to access some other https site but not http site. What did I miss?

manifest.json

{
  "name": "My Extension",
  "description": "modify page",
  "version": "0.3",
  "permissions": [
    "activeTab", "http://www.w3schools.com/*"
  ],
  "content_scripts": [ {
    "js": [ "jquery-3.1.0.min.js", "myscript.js" ],
    "matches": [ "https://www.google.com/*" ]
  }],
  "manifest_version": 2
}

myscript.js

$.ajax({
    type: "GET",
    url: "http://www.w3schools.com",
    success: function(data){
        alert(data);
    },
    error: function(XMLHttpRequest, textStatus, errorThrown) {
        alert(XMLHttpRequest.statusText + " : " + textStatus + " : " + errorThrown);
    }
});

This goes to error block and shows empty response.

kishoreballa
  • 67
  • 1
  • 3
  • 1
    There are lots of answers on that topic, in short: use a background/event page [Since v38, Chrome extension cannot load from HTTP URLs anymore, workaround?](https://stackoverflow.com/a/26286816) – wOxxOm Sep 20 '16 at 21:17
  • Not completely true. I'm able to access HTTP URLs fine if the content_scripts matches another HTTP URL instead of HTTPS. – kishoreballa Sep 20 '16 at 21:31
  • In the discussed context it is completely, 100% true. But of course you're free to ignore the solution. – wOxxOm Sep 21 '16 at 06:20

0 Answers0