Greasy Fork is available in English.

Twitter/X - clickable links to images and show uncropped thumbnails

All image posts in Twitter/X Home, other blog streams and single post views link to the high-res "orig" version. Thumbnail images in the stream are modified to display uncropped.

< Feedback on Twitter/X - clickable links to images and show uncropped thumbnails

مراجعة: OK - script works, but has bugs

§
Posted: 13-08-2023

The script half works. When opening an image in a tab, it shows an "HTTP ERROR 404" where jpg is replaced by webp. If this works for you, tell us how to fix the problem or at least, fix your script.

marpمؤلف
§
Posted: 13-08-2023

Same ask as in the other thread - please provide a sample url of a post that doesn't work for you.
All posts in my feed are solely jpg, not a single webp that I can find.

If I have a sample of the breakage, it's likely very easy to fix the script - without it, however...

§
Posted: 03-09-2023

A tweet with an image.

https://twitter.com/asai_music/status/1698276417463857222

When you middle click the image, the link you receive is:

https://pbs.twimg.com/media/F5F9ZoKa4AA_r1R?format=webp&name=orig

This makes it webp which breaks.

If you left click the image in the tweet first:

https://twitter.com/asai_music/status/1698276417463857222/photo/1

And then right click, open in new tab, it works.

https://pbs.twimg.com/media/F5F9ZoKa4AA_r1R?format=jpg&name=orig

No other scripts running or any of that. Just want middle clicking to work again.

marpمؤلف
§
Posted: 04-09-2023

@Electric Oven

Thank you for these links!
Yeah, so, Twitter/X is definitely doing A/B Testing - it serves different versions of the Twitter page to different users for testing purposes :-(
-> I do not get any webp for this tweet!

And while the webp link you posted (https://pbs.twimg.com/media/F5F9ZoKa4AA_r1R?format=webp&name=orig) doesn't work for me, either... I don't even get a 404 - just an empty, blank page, instead...

So, I cannot properly develop and especially not test a fix for this issue...
...but with the links you posted, I can try to develop a brute-force resolution (will be a bit inefficient, but it should work)
-> I'll see what can be done. This will take some time.

Cheers.

marpمؤلف
§
Posted: 12-09-2023

@Electric Oven

Please have a look at the 4.0 version of this script.

While I still do not get any "webp" myself, I used the links you posted to develop a solution.
-> Whenever a Twitter/X "webp" image is opened directly -> the script tests if it fails, and in such a case searches for a valid image for the other Twitter-supported image types (jpg, png, jpeg, jfif, pjpeg, pjp).

NOTE: "Right click | Save LINK AS" within a stream will not work for such links - the url correction only occurs after opening the image itself in a new tab.

Please test and provide feedback..

§
Posted: 18-09-2023

Sorry for the delay.

This update still redirects to "format=webp&name=orig" when opening the image in a new tab.

I'll try to provide more information.

With every single extension/userscript disabled, opening a twitter image in a new tab gives me:

https://pbs.twimg.com/media/F5F9ZoKa4AA_r1R?format=webp&name=small

marpمؤلف
§
Posted: 18-09-2023

@Electric Oven

The goal is NOT to be stuck with "small" urls - those are exactly what we do not want...

Yes, the script will still generate links to "format=webp&name=orig".

However, when such a webp-orig link is opened in a new tab, the following should now happen:
- script in new tab checks if a 404 has been encountered.
- If 404, then the script will "try" other image urls in the background (especially jpg-orig and png-orig).
- If one of these url-tests succeeds, then that new url is used instead of the non-working webp-orig. I.e., the script will change the new tab's url to, for example, "format=jpg&name=orig".

CAVEAT:
I've developed this with Firefox, and some of the 404 detection behavior can theoretically be browser-dependent.
I've tried to make it browser-independent - but I have only tested with Firefox.

-> What browser are you using?
-> Which "monkey-extension" are you using? TamperMonkey? GreaseMonkey?
-> What behavior are you experiencing if you open a "format=webp&name=orig" image url in a new tab?

§
Posted: 21-09-2023

I'm using Chrome and Tapermonkey.

When I open a "format=webp&name=orig", I'm met with HTTP ERROR 404.

With the script updated to 4.1, the behavior has not changed.

marpمؤلف
§
Posted: 22-09-2023

Bad news - I'll need more time for this!

It turns out that my chosen approach works fine with Firefox - but will never work with Chrome :-(
There is another solution path - but it is quite inefficient (additional network traffic for EVERY image in EVERY post).
I have to do some research to see if there is a way to reduce or eliminate the inefficiency.
Problem is that I might not be able to do that research properly while I'm not exposed to the Twitter webp images, myself, yet.

I might have to go with the inefficient solution - but I'm not ready to give up on finding a better way, just yet.


Technical blabla, in case you're interested:

It turns out that Chrome and Firefox are fundamentally different in how they handle urls that encounter http errors (like the 404 error here).

Firefox tries to load the url, gets the 404 and then auto-generates error html content that takes the place of the 404 page.
In other words, a full and valid tab is loaded in Firefox, under the 404 url (like "format=webp&name=orig").
-> The UserScript triggers because the url matches the Twitter domain...
=> window.location.href = 'https://pbs.twimg.com/media/F5F9ZoKa4AA_r1R?format=webp&name=orig'

Chrome, on the other hand, tries to load the url, gets the 404 and then navigates to a pre-defined error-url that is used to display the 404 error..
In other words, the tab that displays the 404 error is NOT the 404 Twitter url - instead, it is an internal Chrome url ("chrome-error://chromewebdata/").
-> The address bar of the tab does display the proper 404 Twitter url - but the content actually loaded in the tab is something else and is not accessible to TamperMonkey.
-> The UserScript does not trigger as "chrome-error://chromewebdata/" does not match a Twitter url (and it cannot be made to match, "chrome-error" is exempt)...
=> window.location.href = 'chrome-error://chromewebdata/'
=> loadTimeData.data_.summary.failedUrl = 'https://pbs.twimg.com/media/F5F9ZoKa4AA_r1R?format=webp&name=orig'

§
Posted: 25-09-2023

Thank you for all the work you're doing. Actual hero.

marpمؤلف
§
Posted: 29-09-2023

New attempt with script version 4.2.
This should now work with both Chromium browsers and Firefox.

A WebP image should initially open in a new tab as "format=webp&name=small" (or anything else that is not "name=orig").
Within less than a second or so, it should then be replaced by the appropriate "name=orig" image (e.g. "format=jpg&name=orig").

Please test and let me know - I still do not receive the WebP image URLs from Twitter/X, myself (still A/B testing, it appears).

§
Posted: 01-10-2023

It works perfectly now. Thank you!

marpمؤلف
§
Posted: 01-10-2023

Excellent - thank you for the feedback and for posting the sample links!

Post reply

تسجيل الدخول إلى مرحلة ما بعد الرد.