There is a page (game), which communicate via WebSocket to the server. I can see the data (frames) in the Chrome Developer Tool. Is it possible to access / modify this communica
Currently, the only way to access or modify Websocket traffic is to use a content script to inject a script that replaces the WebSocket
constructor with your own wrapper. This wrapper should behave like the original WebSocket implementation, but you can add more stuff, like logging the sent/received messages to your extension.
To prevent sites from breaking, you must make sure that your WebSocket
wrapper is fully standard-compliant. The interface that has to be implemented is documented at http://www.whatwg.org/specs/web-apps/current-work/multipage/network.html#the-websocket-interface.
For inspiration on how to wrap a DOM constructor, see e.g. my wrapper for Worker. You are free to re-use parts of the code (e.g. the implementation of the EventTarget
interface, which is also a requirement of the WebSocket
API).
More emphasis: Make sure that your implementation adheres to the interface of the standard WebSocket API, or you could break some sites!