The easy way is to not use GreaseMonkey for this and to use an add-on that modifies the UserAgent before the request is sent. If the check is server-side, this won't work.
But anyway, you could try what Max suggests here.
So, something like this:
var fakeAppVersion = function () {
return "MSIE 9.0;";
};
if (Object.defineProperty) {
Object.defineProperty(navigator, "appVersion", {
get: fakeAppVersion
});
} else if (Object.prototype.__defineGetter__) {
navigator.__defineGetter__("appVersion", fakeAppVersion);
}
Remember to use
// @run-at document-start
Edit: That might not work I suppose if the check is done before that snippet has a chance to run. In that case, you could use the GM_xmlhttpRequest like you tried, but have it open in a new tab. [You'll probably need to disable the popup blocker for this site I guess].
Greasemonkey has gotten fairly annoying with security (at least on firefox, where I'm testing) Brock's solved the issue here. Modifying his code to suit your needs, I got this (which works AFAIK):
if (window.location.href != 'about:blank') {
GM_xmlhttpRequest({
method: 'GET',
url: window.location.href,
headers: {
'User-Agent': 'Mozilla/4.0 (compatible; MSIE 9.0;) Greasemonkey',
'Accept': '*/*',
},
onload: function(response){
var data = response.responseText;
addJS_Node (null, null, fireNewTab, data, fireNewTab );
}
})
function fireNewTab (data) {
var newTab = window.open ('about:blank', '_blank');
newTab.addEventListener (
"load",
function () {
//--- Now process the popup/tab, as desired.
var destDoc = newTab.document;
destDoc.open ();
destDoc.write (decodeURI(data));
destDoc.close ();
},
false
);
}
function addJS_Node (text, s_URL, funcToRun, data, runOnLoad) {
var D = document;
var scriptNode = D.createElement ('script');
if (runOnLoad) {
scriptNode.addEventListener ("load", runOnLoad, false);
}
scriptNode.type = "text/javascript";
if (text) scriptNode.textContent = text;
if (s_URL) scriptNode.src = s_URL;
if (funcToRun) scriptNode.textContent = '(' + funcToRun.toString() + ')("' + encodeURI(data) +'")';
var targ = D.getElementsByTagName ('head')[0] || D.body || D.documentElement;
targ.appendChild (scriptNode);
}
}
You will need to // @grant GM_xmlhttpRequest ofcourse..