I think they are clamping down and trying to force people to watch yt in Google’s desired way. They have managed to stop most Piped instances via ip banning and also requesting users to “sign in to confirm you are not a robot”. I wish their was a proper alternative at this point. It would be great if something like Peertube took off.
There is a similar thing already written, minus the automatic part. You set it as your default browser and lets you do all sorts of things to the link before opening it in a browser. It lets you choose which app to use the link in afterwards. You can unshort urls, it checks for malware or redirects… You get the picture. Not sure if this helps with what you are after:
https://f-droid.org/packages/com.trianguloy.urlchecker/