docs: describe the shared pattern and the sidebar entry

This commit is contained in:
2026-11-13 22:34:31 +01:00
parent dea2569fd7
commit ea28ad29ac
3 changed files with 14 additions and 8 deletions
+6 -2
View File
@@ -34,14 +34,18 @@ One line per decision, with the reason.
## Client injection
- Registration with File Transformation is done purely by reflection, including building the payload: the `JObject` is created by calling `Parse` on the parameter type of `RegisterTransformation`, so the plugin has no Newtonsoft reference of its own.
- The file pattern is `^index\.html$`. File Transformation treats patterns as regular expressions, and the unanchored `index.html` also matched the script chunk `session-login-index-html.<hash>.chunk.js`, which broke the login page. Found in the container test.
- The transformer leaves anything without a `</body>` alone, as a second line of defence against touching non-HTML files.
- The file pattern is the literal `index.html`, the same string every other plugin registers. File Transformation groups callbacks by pattern string and, for a request, runs only the group whose key equals the requested path; a regex fallback is used only when no key matches exactly. The earlier anchored `^index\.html$` was therefore never called once MediaBar (or any plugin using `index.html`) was installed. Found by reproducing a server with MediaBar and Jellyfin Enhanced.
- As a regular expression `index.html` also matches script chunks such as `session-login-index-html.<hash>.chunk.js`, so those are handed to the callback too. The transformer returns anything that is not an HTML page (`<html` and `</body>` present) unchanged.
- The script tag uses the relative URL `../Herald/client.js` so it keeps working behind a base URL.
- `GET /Herald/client.js` is anonymous: a `<script>` tag cannot send Jellyfin's auth header, and the file holds nothing secret.
- Jellyfin 10.11 has **no "Custom HTML" setting** (branding only offers custom CSS, a login disclaimer and the splash screen; checked against `BrandingOptions`). The documented manual fallbacks are therefore the JavaScript Injector plugin and editing `index.html`.
- Login and user switches are detected by comparing `ApiClient.getCurrentUserId()` on a 3 s local timer. That costs no request; the server is only asked after a change of user and then at most every 10 minutes. jellyfin-web's own login events are not reachable from an injected script in a stable way.
- The modal reuses jellyfin-web's `dialog`, `raised`, `button-submit` and `emby-button` classes so the active theme colours it; own CSS only handles layout.
## Admin UI
- The config page is flagged `EnableInMainMenu`, so it has its own entry in the dashboard sidebar under "Plugins". Jellyfin 10.11 draws a fixed icon there; `MenuIcon` is set for versions that honour it.
## Watch-time stats
- Time is measured on the **server clock between two reports** of the same playback, not from playback positions: a seek changes the position by minutes without anyone watching, and position deltas also break with playback speed.