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

Investigate GM.fetch implementation #467

Open
ACTCD opened this issue Apr 19, 2023 · 6 comments
Open

Investigate GM.fetch implementation #467

ACTCD opened this issue Apr 19, 2023 · 6 comments
Labels
enhancement Feature work help wanted Extra attention is needed

Comments

@ACTCD
Copy link
Collaborator

ACTCD commented Apr 19, 2023

Similar to GM.xmlHttpRequest, but more modern. Support for streaming features etc.

Investigate whether Cross-origin access can be achieved with something like GM.xmlHttpRequest or otherwise.

Compared to XMLHttpRequest this may be a more complex and bulky wrapper and bridge.

The goal is to follow the standard Fetch API as much as possible.

GM.fetch is just a temporary name, which may be different according to the actual situation.

There is no ETA.

@maltoze
Copy link

maltoze commented Apr 27, 2023

I have implemented a similar thing in this repo.

related code:
https://github.com/yetone/openai-translator/blob/ffe58e170d49480f2d2c417c8de2b2c2d039104f/src/background/index.ts#L28
https://github.com/yetone/openai-translator/blob/main/src/common/background-fetch.ts

what do yout think? willing to send a pr to support streaming feature.

@ACTCD
Copy link
Collaborator Author

ACTCD commented Apr 27, 2023

@maltoze Thank you for your comment. I need to learn more to accurately assess this issue, which may take some time.

@quoid quoid added enhancement Feature work and removed feature labels May 1, 2023
@kryptoniancode
Copy link

WebSocket feature in userscript similar to GM_xmlhttpRequest like GM_webSocket.

https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API

Motivation

I want to use websocket for request with url wss://. It is not possible with GM_xmlhttpRequest, I have tried but the request changed to https.

Proposed Solution

Similar to WebSocket class present in browser.

Use Cases

@ACTCD
Copy link
Collaborator Author

ACTCD commented Jan 21, 2024

@kryptoniancode I don't understand what you are talking about.

Are you having problems using original WebSockets_API directly?

xhr is not the correct API for ws, as well as fetch, why are you commenting under this issue?

@ACTCD
Copy link
Collaborator Author

ACTCD commented Jan 21, 2024

@kryptoniancode
As far as I know, currently WebSocket is not subject to CORS policy.
https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS#what_requests_use_cors

If you do find this has changed, please cite your sources.

According to the error log you quoted, you are experiencing a CSP issue.
Currently page context CSP restrictions in Safari cannot be bypassed. Refer to #106

@kryptoniancode
Copy link

Thanks, I have check on some checked on some website it is working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Feature work help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

5 participants
@quoid @maltoze @ACTCD @kryptoniancode and others