BetterTwitFix icon indicating copy to clipboard operation
BetterTwitFix copied to clipboard

Add Nitter redirection support

Open MarshDeer opened this issue 1 year ago • 3 comments

I'm opening this draft PR very early in the process so that I can share my work for transparency and cooperation purposes.

I've begun working on support for more preferences, starting with the option to make vx redirect into a chosen Nitter instance instead of X/Twitter. This one goes for those of us who are exhausted of people sending links we can't read because we don't have an account.

The user will query the status.d420.de API and get a list of healthy instances they can use. Their selected instance will get saved in localStorage, and openLink() will check this preference and act accordingly.

This feature will be incompatible with the "Open in app" function, but users who have the app installed probably don't need or want to use Nitter anyways.

LibRedirect and similar browser extensions might be a better option for this? It could still fit someone's use case, I guess.

MarshDeer avatar Sep 06 '24 01:09 MarshDeer

This feature will be incompatible with the "Open in app" function Might be best to disable either option when the other is checked as well, so there's less confusion

dylanpdx avatar Sep 06 '24 12:09 dylanpdx

Might be best to disable either option when the other is checked as well, so there's less confusion

Shouldn't cause any problems in practice, really, since the "open in app" setting would trigger before there's a chance for the user to be redirected to nitter.

It would be a good idea to check for conflicts between preferences, though. I'll add a quick "is this incompatible with anything else" check later

MarshDeer avatar Sep 06 '24 22:09 MarshDeer

I propose maybe renaming openInApp.js to openTweet.js or redirect.js or something similar since its functions will now go beyond opening tweets in the app? Desktop-only users who will never see the app go through it, after all

That aside, I think everything should be functional now! I'll rest for a bit and reread the entire PR later to make sure, but I'm knocking on wood and marking it as ready for review

MarshDeer avatar Sep 07 '24 00:09 MarshDeer

Getting an error on test:

Uncaught ReferenceError: frontendUrl is not defined
    openTweet /openInApp.js:25

I think you might need to assign localStorage.getItem("frontendUrl") to a variable named frontendUrl so that it can be used in the redirect Or you could also do

window.location = `${localStorage.getItem("frontendUrl")}/i/status/${tweetId}`

I'm fine with both options!

dylanpdx avatar Sep 07 '24 19:09 dylanpdx

Whoops. Knew I was gonna miss something dumb like that. On it~

MarshDeer avatar Sep 07 '24 23:09 MarshDeer