--- name: nekocap-extension-messaging description: Use when modifying communication between the extension's background, content, popup, or canvas-iframe processes — adding or renaming a ChromeMessageType, changing the manifest's content-script matches, adding a new video platform, or anything touching MV3 CSP / cross-browser (Chrome vs Firefox) behavior. --- This skill covers the contract between the four extension processes (background, content, popup, canvas iframe) and the Manifest V3 / cross-browser constraints around them. ## The message contract lives in `src/common/types.ts` `ChromeMessageType` is the enum that names every message that crosses a process boundary. The current set: ```ts enum ChromeMessageType { Route, GetProviderType, GetTabId, ContentScriptUpdate, SaveFile, RawCaption, InfoMessage, GetContentScriptVariables, Request, // XMLHttpRequest proxied via background ProviderRequest, // BackendProvider call proxied via background VideoIframeToBackground, VideoIframeToContent, } ``` Plus `ParentToCanvasIframeMessageType` / `CanvasIframeToParentMessageType` for the Octopus renderer iframe, and `ChromeExternalMessageType` (`GoogleAuthCredentials`) for OAuth completion. **There is no compile-time check that all senders match all receivers.** A mismatch fails silently at runtime. Treat changes to this enum like a public API change. ## Adding a new message — 5 steps 1. **Add the entry** to the appropriate enum in `src/common/types.ts`. 2. **Define its payload** — either extend `ChromeMessage` (loose typing) or add a variant to the discriminated union that fits (e.g. `ParentToCanvasIframeMessage`). 3. **Add the handler.** Background hub: `src/extension/background/index.tsx`. Content: `src/extension/content/index.tsx`. Popup: `src/extension/popup/index.tsx`. Canvas iframe: `src/extension/content/canvas-iframe/`. 4. **Add the sender** in whichever process initiates the message. 5. **If the message participates in a Redux flow that touches persisted state**, verify the state shape still serializes cleanly through `reduxed-chrome-storage` (see the `nekocap-redux-feature` skill). ## Renaming or removing a message Search every directory for the old name: `background/`, `content/`, `popup/`, `canvas-iframe/`, and `src/common/`. A missed sender will silently no-op — the receiver just won't fire. Lint and type errors will not catch this. ## MV3 CSP is restrictive `extension_pages` CSP allows only `'self'`, `*.google.com`, and `'wasm-unsafe-eval'`. The following silently break the extension on load: - CDN-loaded scripts (jsdelivr, unpkg, …) - Inline `