Last active
December 14, 2017 22:47
-
-
Save mk-pmb/22b0b3d9f0f704966007347dd2168c5d to your computer and use it in GitHub Desktop.
Sync XHR is broken as well
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* -*- 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