Tampermonkey / tampermonkey

Tampermonkey is the most popular userscript manager, with over 10 million users. It's available for Chrome, Microsoft Edge, Safari, Opera Next, and Firefox.
GNU General Public License v3.0
4.28k stars 423 forks source link

onprogress doesn't return response/responseText, even when it's available #906

Open qsniyg opened 4 years ago

qsniyg commented 4 years ago

Expected Behavior

The script below should output "Good" a few times, as responseText should be available if loaded > 0. This is how Violentmonkey behaves.

Actual Behavior

The script outputs "Bad", as responseText isn't available

Specifications

Script

// ==UserScript==
// @name         New Userscript
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       You
// @match        https://www.google.com/
// @grant        GM_xmlhttpRequest
// ==/UserScript==

(function() {
    'use strict';

    GM_xmlhttpRequest({
        url: "https://www.google.com/logos/doodles/2020/thank-you-public-transportation-workers-6753651837108759-law.gif",
        method: "GET",
        onprogress: function(resp) {
            if (resp.loaded) {
                console.log(resp.responseText ? "Good" : "Bad");
            }
        }
    });
})();
derjanb commented 3 years ago

1278 might help here.