Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No support of GM_* functions, no abort of GM.xmlHttpRequest? #3142

Closed
AlttiRi opened this issue May 25, 2022 · 1 comment
Closed

No support of GM_* functions, no abort of GM.xmlHttpRequest? #3142

AlttiRi opened this issue May 25, 2022 · 1 comment

Comments

@AlttiRi
Copy link

AlttiRi commented May 25, 2022

I have installed Greasemonkey 4.11 from Firefox Store.
Firefox 100.0.2. The same with 91.9.1esr.

GM_xmlhttpRequest, GM_log do not exist.
GM.xmlHttpRequest does not return {abort} object.

The example from 2015 year' issue — #2154:

// ==UserScript==
// @name        Abort Test
// @namespace   gmscripts
// @include     http*://*/*
// @grant       GM_log
// @grant       GM.xmlHttpRequest
// @grant       GM_xmlhttpRequest
// ==/UserScript==

const req = GM_xmlhttpRequest({ // ReferenceError: GM_xmlhttpRequest is not defined
//const req = GM.xmlHttpRequest({ // It works.
  method: "GET",
  url: "https://github.com/",
  onload(gmResponse) {
    console.log(gmResponse.responseText);
  },
  onabort() {
    console.log("on abort");
  }
});

req.abort();  // TypeError: req is undefined
GM_log("completed"); // ReferenceError: GM_log is not defined

...does not work.

What's the problem?

I think it should work.

@w35l3y
Copy link

w35l3y commented Aug 2, 2022

Starting at version 4, there isn't GM_* anymore.
https://wiki.greasespot.net/GM.xmlHttpRequest

GM.* returns a promise.
That is the reason why you don't have req.abort()

I haven't tested it, but try using:

(async function () {
  const req = await GM_xmlhttpRequest(...);
  req.abort()
})()

or

GM_xmlhttpRequest(...).then(req => req.abort())

@arantius arantius closed this as not planned Won't fix, can't repro, duplicate, stale Nov 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants