I'm send XMLHttpRequest
and want to send it only to real domains, which are not null and are not Chrome's internal chrome:
domains.
Until now i fail on this - my XMLHttpRequest
is sending under any circumstances - but in case of currentDomaon == 0
or currentProtocoll == "chrome:"
it comes empty.
What i'm doing wrong? How should i adapt the code to get the goal?
var currentDomain = "";
var currentProtocol ="";
const processingTabId = {};
function run(tab) {
if (processingTabId[tab.id]) return;
processingTabId[tab.id] = true;
let newUrl = new URL(tab.pendingUrl || tab.url)
currentDomain = newUrl.hostname;
currentProtocol = newUrl.protocol;
var xhr = new XMLHttpRequest();
var protocol = "https://";
var middle = ".myservice/"
var end = "/action/data/";
xhr.open("GET", protocol + middle + currentDomain + end, true);
xhr.responseType = 'document';
if (currentDomain !== null) && (currentProtocol !== "chrome:") {
xhr.send();
}
}