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

I wonder, is there a chance you could make an userscript out of this? #5

Open
TsukiZero opened this issue Nov 12, 2023 · 2 comments
Open

Comments

@TsukiZero
Copy link

just for convenience for users that may need to patch it themselves if Reddit does something.

@a-pav
Copy link

a-pav commented Jan 10, 2024

I think it will most likely introduce an infinite loop.
In a userscript, AFAIK, best option to use for this case is // @run-at document-start pragma, which is good for redirecting the HTML interface to the direct-image-url but upon loading that url — since the headers are set to NOT accept a direct image — it will get redirected back to the HTML interface once again; just like when you try to open the direct-image-url in a new tab.

Eidt: I don't think the more advanced GM_ options can give access to HTTP headers either. see this.

@themojache
Copy link

just for convenience for users that may need to patch it themselves if Reddit does something.

Here is my attempt: https://github.com/themojache/userscripts/blob/main/reddit-image-redirect.user.js.

  • This script has some alterations, I find it works better for my purposes (/gallery/ endpoint support and old reddit gallery support mainly).
  • Base64 DataURL's are not ideal (image file size expands to 4/3 of the original file size), but makes original images viewable without an extension. This script generates DataURL's on demand locally, after fetching the image in a similar manner.

Feel free to open an issue/PR for suggestions.

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