I'm trying to use the Chrome Extension to get a content of a site when browsing a other site. I'm calling "XMLHttpRequest" in the occurrence of chrome.webRequest.onCompleted But whenever I call the method XHR.Open get the following error: [Exception: DOMException] in fields Status and StatusText from XHR object.
Any idea ?
Thanks.
I am using the code below:
chrome.webRequest.onCompleted.addListener(
function(details) {
if (details.url.substring(0, 23) == "https://www.google.com/") // I know I do not need this
{
console.info("URL :" + details.url);
FindData("www.altavista.com");
}
},
// filters
{
urls: [
"http://*.google.com/*",
"https://*.google.com/*",
],
types: ["image"]
},
["responseHeaders"]);
function FindData(strURL) {
var req = new XMLHttpRequest();
req.open("GET", strURL, true);
req.onreadystatechange=function() {
if (req.readyState==4) {
if (req.status==200)
{
console.info("Sucess!");
console.info("Data: " + req.responseText);
}
else if (req.status==404) console.info("URL doesn't exist!")
else console.info("Error: Status is " + req.status)
}
}
req.send();
}
My manifest.json
{
"name": "Test",
"version": "1.0",
"manifest_version": 2,
"description": "The first extension that I made.",
"browser_action": {
"default_popup": "popup.html"
},
"permissions": ["webRequest", "webRequestBlocking",
"http://www.altavista.com/*",
"http://*.google.com/*",
"https://*.google.com/*"]
}