从Chrome扩展访问Websocket流量 [英] access Websocket traffic from chrome extension
问题描述
目前,访问或修改Websocket流量将使用内容脚本 插入脚本,替换 WebSocket
构造函数与你自己的包装。这个包装应该像原来的WebSocket实现一样,但是你可以添加更多的东西,比如记录发送/接收到的消息到你的扩展。
为了防止网站破坏,你必须确保你的 WebSocket
包装完全符合标准。必须实现的接口记录在 http://www.whatwg.org/specs/web-apps/current-work/multipage/network.html#the-websocket-interface 。
有关如何包装DOM构造函数的启示,请参阅例如我的 <$ c $的包装C>工人 。您可以自由地重用部分代码(例如 更强调:确保您的实现符合标准WebSocket API的接口,否则您可能会破坏某些网站! 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 communication from a chrom-extension? Currently, the only way to access or modify Websocket traffic is to use a content script to inject a script that replaces the To prevent sites from breaking, you must make sure that your For inspiration on how to wrap a DOM constructor, see e.g. my wrapper for More emphasis: Make sure that your implementation adheres to the interface of the standard WebSocket API, or you could break some sites! 这篇关于从Chrome扩展访问Websocket流量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! EventTarget
接口的实现,这也是 WebSocket $>的要求c $ c> API)。
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.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.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).