Userscripts - How to redirect without connecting to target website first?

2 respuestas [Último envío]
GNUser
Desconectado/a
se unió: 07/17/2013

Hi.

I have seen some userscripts that redirect websites like Youtube to Invidious, Twitter to Nitter, etc. Example below, and I am running them with ViolentMonkey.
Now my problem with these is that I notice they still allow the browser to connect to Youtube, Instagram, Twitter, etc, they will even load the page for a few seconds, before actually redirecting to Invidious, Bibliogram, Nitter, etc. That is very bad from a privacy perspective, so I would like to know if it's possible to write a script that will actually intercept the connection attempt BEFORE connecting and redirect safely.

I know there are other options like LibRedirect and etc, but I think userscripts have other interesting functionalities that I would like to take advantage of. Also, I am curious if this is even possible to do :)
Thanks for all help you might provide!

Example:
https://greasyfork.org/en/scripts/437398-twitter-to-nitter

andermetalsh
Desconectado/a
se unió: 01/04/2013

Add youtube, twitter and so on to your /etc/hosts file :)

Append at the end:

127.0.0.1 .youtube.com

And so on.

GNUser
Desconectado/a
se unió: 07/17/2013

That... is actually a good idea, I had not thought of that!
However, I want it to be a usable solution with the Tor Browser, which will not work through my hosts file.

The idea is pretty good in any case ;) thanks for the suggestion!