Skip to content

Instantly share code, notes, and snippets.

Last active October 21, 2020 12:26
  • Star 9 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
// ==UserScript==
// @name GM_download emulation
// @namespace
// @version 0.1
// @description emulate GM_download functionality
// @require
// @match
// @grant GM_xmlhttpRequest
// @copyright 2014, Jan Biniok
// ==/UserScript==
var GM_download_emu = function(url, name) {
method: 'GET',
url: url,
onload: function(r) {
var bb = new Blob([r.responseText], {type: 'text/plain'});
saveAs(bb, name);
GM_download_emu('', 'favicon.ico' /* .exe .sh .crx*/);
Copy link

martixy commented Mar 12, 2016

Or maybe responseType: "blob",, then saveAs(r.response, name);.
You see, this version doesn't really work in some cases(images, so far as I've discovered).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment