invidious
invidious copied to clipboard
Show available actions on embed error page
Context
If you have privacyRedirect installed in your browser, any embedded youtube videos are automatically replaced by an invidious equivalent on pages you visit. The trouble is, often embeds don't always work - if 1/ the selected instance is down; 2/ the video is blocked or similar.
Current flow
If you particularly want to watch the video, you might right-click the iframe, click open in new tab, then replace the /embed/
part of the url with /watch?v=
- or replace the domain with youtube.com
to see the youtube version of it (but still as an embed)
Desired flow
It would be great if you had the same actions available on regular video error pages (switch instance / watch on youtube / refresh)
Caveats
It's worth noting that different browsers handle links inside iframes differently; eg. firefox often prompts you to open the link in a new tab - which IMO is ok, because if you are interested enough in the video to want to watch it, you would probably prefer to at least have this automatically, rather than doing it manually?
Chrome, on the other hand, doesn't even give you the option to "open frame in new tab" when you right click it, but it does seem to follow urls within the frame
Summary of changes in PR
- Add
request_path.starts_with?("/embed")
check toerror_redirect_helper
- Move HTML string from error_redirect_helper into separate template
- Add unit tests for
error_redirect_helper
- Add
ContextWithPreferences
andtest_env
helpers to help with test setup/compilation
The first point is obviously the main functional change, and the latter 3 are IMO code quality improvements (so they can be modified/removed if they are not helpful here)
Testing
I don't have this set up fully e2e locally so haven't checked this fully, but I found the unit tests went a decent way to verifying the behaviour I wanted