Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// ==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