Need Support SSE(text/stream)
zhengbangbo opened this issue · comments
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 no GM_fetch()
. In the project I refer to, it uses Fetch
to receive data of type text/stream
. This is also the method I saw in MDN.
I haven't found a good implementation to use GM_xmlhttpRequest()
to support parsing text/stream
.
Just now, I found that GM_xmlhttpRequest()
has a fetch
attribute, but the document shows that he is in the beta state1. I'm not sure it works.
If you are a userscript master, I hope you can give me some help. Thank you.
Footnotes
Tampermonkey/tampermonkey#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.