I read about this here and here, but still I couldn't figure out how to do it in jQuery ajax. I tried the code from one of the answers of the questions I linked, but it discarded the user agent override:
$.ajax({
url: "http://blablabla.com/",
dataType:'html',
beforeSend: function (req) {
req.setRequestHeader('User-Agent', 'https://graphicdesign.stackexchange.com/users/69916/vikas');
},
error: function() { alert("No data found");},
success: parseResult
});
My current User-agent string that is being sent is this:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.40 Safari/537.36 Edg/92.0.902.9
And I want to add my other SE profile URL too, in this which is https://graphicdesign.stackexchange.com/users/69916/vikas
I want to do this because it has been suggested here in case you're involved in chatbots.
A simple example about how to put additional information, i.e., my profile URL in existing User-agent and send it using ajax to any api, would help.
fetch(set the UA to whatever):(async () => { const res = await fetch(location.href, { method: "GET", headers: { "User-Agent": navigator.userAgent } }); console.log(res); })();User-Agentheader was removed from the list of forbidden headers, the paths diverged - it seems like Chromium-based ones still thinks it is an unsafe header, while Firefox has no problems with it. Since jQuery usesXMLHttpRequestunder the hood, you won't be able to override in those browsers (at least now). As for the MSE post of Jeff, I think they did not even think of someone requesting from JS back then, it was 2009 after all