Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
danmaku-anywhere-web | a3683e8 | Commit Preview URL Branch Preview URL |
Mar 18 2026, 01:24 AM |
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly refactors the extension's content script injection strategy for the player component. By moving from a manual, polling-based injection mechanism to a declarative approach via the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request refactors the content script injection and frame management logic for the extension. It introduces a new player content script that is injected into all frames at document_start via the manifest, replacing the previous dynamic injection mechanism handled by ScriptingManager and FrameInjector. The ScriptingManager and FrameInjector services have been removed, and their responsibilities for tracking and managing frames are now handled by a new FrameRegistry service and integrated into the FrameManager component. The RPC system has been enhanced to support optional calls and new player lifecycle events (playerReady, playerUnload, controllerReady), improving the robustness of communication between the controller and player scripts, especially during frame reloads and initial handshakes. The FrameState in the store no longer directly stores documentId, as this is now managed internally by the FrameRegistry to differentiate between script retries and frame reloads.
There was a problem hiding this comment.
Pull request overview
This PR updates the extension’s “player” content-script architecture to be injected globally (all frames, all HTTP(S) pages) and replaces the prior controller-driven per-frame script injection/polling with a lightweight player bootstrap + handshake-driven “heavy” initialization.
Changes:
- Add a globally injected player bootstrap (
PlayerScript) that performs a best-effortplayerReadyhandshake and only initializes the full player handler after receivingstart. - Replace the old frame polling/injection logic (
FrameInjector) with a controller-sideFrameRegistrythat registers/unregisters frames based onplayerReady/playerUnloadevents. - Extend the RPC layer with
RpcOptions.optionalfor best-effort calls and update RPC payload types to include player-ready metadata.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/danmaku-anywhere/src/content/player/index.ts | Simplifies player entrypoint to delegate to PlayerScript bootstrap. |
| packages/danmaku-anywhere/src/content/player/PlayerScript.service.ts | New lightweight bootstrap: lite RPC server, playerReady handshake, transition to full handler. |
| packages/danmaku-anywhere/src/content/player/PlayerCommandHandler.service.ts | New “heavy” handler that owns DOM/event wiring + full RPC command handling after start. |
| packages/danmaku-anywhere/src/content/controller/store/store.ts | Removes documentId from persisted frame state and adjusts addFrame signature. |
| packages/danmaku-anywhere/src/content/controller/danmaku/frame/FrameRegistry.service.ts | New registry tracking documentId per frame to dedupe handshake vs reload. |
| packages/danmaku-anywhere/src/content/controller/danmaku/frame/FrameManager.tsx | Switches to FrameRegistry-based registration and adds controllerReady broadcast + playerUnload handling. |
| packages/danmaku-anywhere/src/content/controller/danmaku/frame/FrameInjector.service.ts | Removes frame polling + manual script injection implementation. |
| packages/danmaku-anywhere/src/common/standalone/standaloneHandlers.ts | Removes obsolete background handlers and adds new relay handlers (controllerReady, playerUnload). |
| packages/danmaku-anywhere/src/common/rpcClient/background/types.ts | Removes getAllFrames/injectScript, adds new relay command/event types and playerReady payload. |
| packages/danmaku-anywhere/src/common/rpc/types.ts | Adds RpcOptions.optional to support best-effort messaging. |
| packages/danmaku-anywhere/src/common/rpc/server.ts | Refactors RPC server into a class and threads options through to handlers. |
| packages/danmaku-anywhere/src/common/rpc/client.ts | Implements optional behavior (suppress errors / return empty response) when calls are best-effort. |
| packages/danmaku-anywhere/src/background/scripting/ScriptingManager.ts | Removes player-script injection helper (no longer needed). |
| packages/danmaku-anywhere/src/background/rpc/RpcManager.ts | Removes getAllFrames/injectScript RPCs and forwards options through relay pass-through. |
| packages/danmaku-anywhere/manifest.ts | Adds globally injected player content_script for all frames on HTTP(S). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| private registerUnloadHandler() { | ||
| window.addEventListener('pagehide', () => { | ||
| void playerRpcClient.controller['relay:event:playerUnload']( | ||
| { frameId: this.frameId }, | ||
| { optional: true } | ||
| ) | ||
| }) |
| run_at: 'document_start', | ||
| all_frames: true, | ||
| // @ts-expect-error -- crxjs types don't include `world`, but Chrome supports it | ||
| world: 'ISOLATED', |
No description provided.