Im making a really simple Chrome extension, what redirects pages what are on http protocol ,to https protocol, if exist. Im on debugging, and i found facebook, what has both http, and https.
The code is here:
function redirect() {
chrome.tabs.query({active: true}, function(tabArray) {
var currentURL = tabArray[0].url; //http://facebook.com
var httpsURL = generateSSL(currentURL); //https://facebook.com
if(httpsURL == currentURL){
console.log(currentURL+" is already on HTTPS");
chrome.browserAction.setIcon({path:"../images/padlock_green.png"});
} else if(checkSSL(httpsURL)){
chrome.tabs.update(tabArray[0].id, {url: httpsURL});
chrome.browserAction.setIcon({path:"../images/padlock_green.png"});
chrome.browserAction.setBadgeText({text:"SSL"});
console.log("SSL found,"+currentURL+" redirected to"+httpsURL);
} else {
//donothing
console.log(currentURL+" has no SSL");
chrome.browserAction.setIcon({path:"../images/padlock_red.png"});
}
});
}
ajax call:
function checkSSL(url){
$.support.ajax = true;
$.ajax({
url: url,
type:'HEAD',
error: function()
{
return false;
},
success: function()
{
return true;
}
});
}
The problem is, that i get in console the following error msg:
XMLHttpRequest cannot load https://www.facebook.com/. Origin chrome-extension://pgidanbjmliilmmohlphbagcapafjjpg is not allowed by Access-Control-Allow-Origin.
I dont have any ideas what could be the problem :(