Make screen capture work in Firefox

Firefox has no tab capture, so preferCurrentTab is silently dropped and the
operator can only share a window or a screen. Neither maps onto the viewport
the way the crop assumes, so screenshots came out offset by the browser chrome
— and every failure was swallowed by a bare catch, leaving no way to tell why.

Check the shared surface and only crop when the viewport covers it: exact for
Chrome's tab capture, true for a screen while the page is fullscreen. Test that
by dimensions rather than document.fullscreenElement, which F11 leaves null.
Start now requests fullscreen, after getDisplayMedia so the click's transient
activation goes to the fragile call. Reasons surface in a corner notice and the
console, and the check reruns per grab so leaving fullscreen says so.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01H9v2Xoa6eoeGYpK6gp95k9
This commit is contained in:
simon
2026-08-10 21:36:58 +02:00
co-authored by Claude Opus 5
parent d3c0268c48
commit cc6ea58c7c
5 changed files with 151 additions and 20 deletions
+19 -5
View File
@@ -100,11 +100,25 @@ effect immediately; while pinned, track changes leave the animation running.
**The corners and trail animations ask to share your screen.** The decks are
cross-origin YouTube iframes, so nothing on the page can read their pixels —
capturing the tab and cropping out the frame is the only way to photograph what
is playing. The prompt appears once, on the first click of **Start**; choose
*this tab*. Declining is fine: the frame still parks in its corner and still
glides, just without the screenshots. The prompt is skipped entirely on a plain-HTTP origin (i.e. when
you open the player from another machine over the network), for the same reason.
capturing the screen and cropping out the frame is the only way to photograph
what is playing. The prompt appears once, on the first click of **Start**, which
also puts the page into fullscreen.
The crop assumes the captured surface *is* the viewport, so what you pick in the
picker matters:
- **Chrome/Chromium** preselects *This tab* — take it, and the mapping is exact.
- **Firefox** has no tab capture; the picker offers only windows and screens.
Choose the **entire screen**. Fullscreen is what makes it line up, so if you
leave fullscreen, press <kbd>F11</kbd> to get screenshots back.
- **A single window** cannot be used: it includes the tab and URL bars, and
Wayland gives the page no window coordinates to subtract.
Declining is fine: the frame still parks in its corner and still glides, just
without the screenshots. The prompt is skipped entirely on a plain-HTTP origin
(i.e. when you open the player from another machine over the network), for the
same reason. Whenever screenshots are off or misaligned, the player says why in
the bottom-left corner and logs it to the console.
## Adding animations