Skip to content

Shogi Wars: add a CSP-safe API for observing page WebSocket traffic #11111

Description

@NKM4

Activity name

Shogi Wars

Description

Shogi Wars is a Unity WebGL/SPA application. Its exact current mode, opponent name, and match lifecycle are emitted through a page WebSocket, but are not exposed reliably through the DOM, URL, or fetch/XHR.

The Activity can identify a broad page state, but it cannot reliably distinguish home, matching, in-match, and replay states; display the opponent; or clear stale match data after returning home without a separate helper extension.

presence.execInPage is not a complete workaround on sites with a strict Content Security Policy. Dynamic function/string evaluation is blocked when script-src does not allow unsafe-eval. A one-shot declarative execution also cannot install a persistent WebSocket listener and continuously deliver events back to the Activity.

Reproduction site: https://shogiwars.heroz.jp/static/webgl/

Please add a CSP-safe, permission-scoped API for observing page WebSocket traffic. An illustrative shape would be presence.onWebSocket(callback) with these properties:

  • observes socket open, message, and close events, including direction;
  • exposes the socket URL and text payloads, with binary payload access opt-in;
  • registers early enough to observe sockets created during page initialization;
  • remains active across SPA navigation and is cleaned up with the Activity;
  • is limited to the Activity's declared domains.

Suggested guardrails include an explicit manifest permission and review, payload-size and event-rate limits, domain filtering, and no ability to mutate sockets.

An equally useful alternative would be a CSP-safe persistent main-world hook plus an event channel back to the Activity.

Alternatives

  • DOM and URL inspection: they do not contain the exact match/opponent state.
  • presence.onRequest: it covers fetch/XHR, not WebSocket frames.
  • presence.execInPage: strict CSP blocks dynamic evaluation, and its declarative form does not provide a persistent event stream.
  • A separate helper extension with a main-world WebSocket hook: this works as a proof of concept, but requiring a second extension prevents a practical official Activity deployment.

Additional context

This API would allow an official Shogi Wars Activity to show home, matching, current opponent, and replay states accurately, and to clear stale status after a match or tab close without requiring users to install another extension.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions