The response
passed to onload
is an object with these key properties:
- readyState
- responseHeaders
- responseText
- status
- statusText
- finalUrl
You want finalUrl
, you get it like:
GM_xmlhttpRequest ( {
synchronous: false,
method: "HEAD",
url: "http://www.google.com",
onload: function (response) {
console.debug (response.finalUrl);
}
} );
Update for revised/clarified question:
In order to get/know the originally requested URL, you must call GM_xmlhttpRequest()
in a closure. Like so:
var origURL = "http://www.google.com";
(function (targURL) {
GM_xmlhttpRequest ( {
synchronous: false,
method: "HEAD",
url: targURL,
onload: function (response) {
console.log ("orig URL: ", targURL);
console.log ("final URL: ", response.finalUrl);
}
} );
} ) (origURL);