It would be good to include the Referer
header as a default, by getting the URL of the current page. Just like with cookies. I was wondering for a long time why my request was not working as it did in the old version, and the JS console.
It was a POST
request that required the referer header to be set to the current page I was on, presumably to stop requests from other pages.
Makes sense to do this automatically for same-origin requests, matching the behavior of both GM_xmlhttpRequest and normal XHR. For cross-origin, the user can manually specify the referrer they want.
GM.xmlhttpRequest does match the behavior of normal XHR. Neither of them sends a referer breaking my code which works in tampermonkey.
And are you sure GM_xmlhttpRequest would send a referer? I have not yet checked the latest greasemonkey version including GM_xmlhttpRequest but by the last comment on https://greasyfork.org/en/forum/discussion/6928/gm-xmlhttprequest-vs-xmlhttprequest it was not the case in 2015.
Most helpful comment
Makes sense to do this automatically for same-origin requests, matching the behavior of both GM_xmlhttpRequest and normal XHR. For cross-origin, the user can manually specify the referrer they want.