TuxedoTako / 4chan-xt

Adds various features to anonymous imageboards.
Other
80 stars 7 forks source link

Fix Twitter embeds #57

Closed irystocratanon closed 1 month ago

irystocratanon commented 2 months ago

Twitframe has been broken for a long time now thanks to elon and Twitter's own embeds are also somewhat unreliable and don't work for NSFW tweets, etc.

Replace it with FxTwitter

Currently they don't have an iframe embed but they do have a simple JSON API that can be used instead.

https://github.com/FixTweet/FxTwitter/issues/774

irystocratanon commented 1 month ago

It's nice to see a pull request instead of an issue, so I'm sorry to disappoint.

* I personally have not noticed problems with the twitframe:
  It might be because I don't usually browse boards with links to nsfw tweets. Maybe you can provide some examples that don't load?

It happens when signed out of Twitter a lot.

* This implementation lacks some things: the one tweet I tested was a quote tweet, the current twitframe shows the quoted tweet, but this doesn't, despite the API returning the data.

I should be able to fix that. I'll look into it. Another thing I don't think is handled right now are polls but that data should be in the API too I think.

I think that is only for the code but they have docs here: https://docs.fxtwitter.com/en/latest/api/about.html

They encourage use of their API.

irystocratanon commented 1 month ago

It handles quotes now. One thing I'm not sure about is nested quotes (a quote that quotes a quote that quotes a quote). I could handle that if the API has the data and I can find a tweet to test with.

TuxedoTako commented 1 month ago

It happens when signed out of Twitter a lot.

I don't even have a twitter account.

I think that is only for the code but they have docs here: https://docs.fxtwitter.com/en/latest/api/about.html

They encourage use of their API.

That does indeed look like permission.

TuxedoTako commented 1 month ago

I'm sensing scope creep. You're adding features after you already opened the pull request. I don't know where to test the reply resolver, which the original twitframe didn't have in the first place. But I already found an issue with the translation: if it's on a quote tweet, it's displayed as: quote tweet -> quoted tweet -> quoted translation -> quote translation.

irystocratanon commented 1 month ago

I don't know where to test the reply resolver

It's for threads. It didn't show any replies (the history, what it's in reply to) before and arguably doesn't need to (which is why I made it configurable) but this can be useful for context.

it's displayed as: quote tweet -> quoted tweet -> quoted translation -> quote translation.

Do you mean the quote translation should be displayed first? That shouldn't be too difficult.

TuxedoTako commented 1 month ago

It's for threads. It didn't show any replies (the history, what it's in reply to) before and arguably doesn't need to (which is why I made it configurable) but this can be useful for context.

Do you have a thread where I can test this? I want to test before I merge the PR.

it's displayed as: quote tweet -> quoted tweet -> quoted translation -> quote translation.

Do you mean the quote translation should be displayed first? That shouldn't be too difficult.

I mean the translations should be grouped with the original text. Now the original tweet is sandwiched between the quote and its translation.

TuxedoTako commented 1 month ago

I haven't found a tweet for 'Resolve all Tweet Replies', but I'm impatient, so I'm merging anyway. I will move the templating to jsx, in case we missed an escape. I fixed the translation order myself.