I’m writing a chrome extension to intercept WebSocket traffic, by hooking the function WebSocket.send
, like:
var _send = WSObject.send
WSObject.send = function (data) {
arguments[0] = my_hook_function(data)
_send.apply(this, arguments)
}
function my_hook_function(data) {
// how to read the data here synchronously?
return data
}
The my_hook_function
should be synchronous. The type of data is Blob, I can’t find a synchronous API for reading the Blob. Google says there is FileReaderSync
but I tried in console and this class does not exist.
How to solve it?