Skip to content

Instantly share code, notes, and snippets.

@jesus2099
Created March 11, 2021 22:18
Show Gist options
  • Save jesus2099/b4d8584d761c42c43da8d0cf3e5d2a62 to your computer and use it in GitHub Desktop.
Save jesus2099/b4d8584d761c42c43da8d0cf3e5d2a62 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name httpbin.org/post XMLHttpRequest Origin header test
// @description Origin is null in Greasemonkey https://github.com/greasemonkey/greasemonkey/issues/3111
// @version 1
// @author jesus2099
// @grant none
// @match *://httpbin.org/*
// ==/UserScript==
var xhr = new XMLHttpRequest();
xhr.addEventListener("load", function(event) {
alert(this.responseText);
});
xhr.open("POST", location.protocol + "//" + location.host + "/post", true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
setTimeout(function() { xhr.send("toto=1&tutu=bob"); }, 1000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment