Closed zhengbangbo closed 1 year ago
https://github.com/Tampermonkey/tampermonkey/issues/1278 is explained that the data is stored in memory before it is fully received, so it is impossible to obtain the data segment by segment, so it cannot be printed verbatim, and it will take a long time to wait.ðŸ˜.
The streaming is the core difference between XMLHttpRequest and fetch.
When you download some data with XMLHttpRequest the entire data stores in the memory until the request is finished and data is handled. In case of a userscript manager extension the consuming of memory is double. Since the data stores both in content/web script and in the background script.
v0.5.0 Tampermonkey support print verbatim
36e88e65e12595e3bbd1cf2a7d6bb9afbcbf7750
At present, there is no verbatim print effect, but the result is printed directly after waiting for a period of time.
This is because there is only
GM_xmlhttpRequest()
in userscript, but there is noGM_fetch()
. In the project I refer to, it usesFetch
to receive data of typetext/stream
. This is also the method I saw in MDN.I haven't found a good implementation to use
GM_xmlhttpRequest()
to support parsingtext/stream
.Just now, I found that
GM_xmlhttpRequest()
has afetch
attribute, but the document shows that he is in the beta state^doc. I'm not sure it works.If you are a userscript master, I hope you can give me some help. Thank you.