access Websocket traffic from chrome extension

后端 未结 5 575
借酒劲吻你
借酒劲吻你 2021-01-31 06:07

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

5条回答
  •  囚心锁ツ
    2021-01-31 07:00

    Seems like the bug is fixed and available. In the manifest.json you need to explicitly specify the permissions

    {
        ...
        "permissions": ["webRequest", "ws://*/*", "wss://*/*"]
        ...
    }
    

    and in the network filters it should be specified as a websocket request.

    const networkFilters = {
        urls: [
            "wss://echo.websocket.org/*"
        ]
    };
    chrome.webRequest.onBeforeRequest.addListener((details) => {
        const { tabId, requestId } = details;
        // do stuff here
    }, networkFilters);
    

提交回复
热议问题