Skip to content

Instantly share code, notes, and snippets.

@mk-pmb
Last active December 14, 2017 22:47
Show Gist options
  • Save mk-pmb/22b0b3d9f0f704966007347dd2168c5d to your computer and use it in GitHub Desktop.
Save mk-pmb/22b0b3d9f0f704966007347dd2168c5d to your computer and use it in GitHub Desktop.
Sync XHR is broken as well
/* -*- coding: UTF-8, tab-width: 2 -*- */
/*jslint indent: 2, maxlen: 80, browser: true */
// ==UserScript==
// @name XHRmonkey test
// @namespace greasemonkey.web-enhance.pimpmybyte.de
// @description
// @match https://gist.github.com/mk-pmb/22b0b3d9f0f704966007347dd2168c5d
// @version 1
// @grant GM.xmlHttpRequest
// ==/UserScript==
'use strict';
/*global GM: true */
(function resTextShim() {
var xhr = { method: 'GET' };
xhr.url = ('http://localhost/xhr-test.php' +
'?host=' + location.hostname);
xhr.synchronous = true;
xhr.timeout = 5e3;
'abort error load progress timeout'.replace(/\S+/g, function (evt) {
xhr['on' + evt] = console.log.bind(console, 'GM XHR ' + evt);
});
console.log('GM XHR go!', xhr);
xhr.result = GM.xmlHttpRequest(xhr);
console.log('GM XHR result:', xhr.result);
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment