Is there a way to block this at the browser level? Ex: block access to localhost for all domains (except from localhost itself)?
*$websocket
will block all websocket connections. You probably want to operate on a whitelist on a site by site basis. Blocking localhost or 127.0.0.1 isn't reliable because sites can use dns rebinding attacks to bypass your filters. *$websocket
Tested with https://websocketstest.com/ ~site.com$websocket
*,~site.com$websocket
However this seems like it's invalid syntax because switching your example to this opens all websocket use back up tested via https://websocketstest.com/ *$websocket,domain=~site1.com
For more than a single site: *$websocket,domain=~site1.com|site2.com|...
I would personally suggest people to just enable advanced user mode and create rules such as: * 127.0.0.1 * blocked
To block all request attempts to 127.0.0.1. *$websocket,domain=~site1.com|~site2.com|~...This is kinda gross practice overall.
* * xhr block
What I actually do is block everything but first-party requests, apart from CSS and images: * * * block
* * cookie block
* * css allow
* * frame block
* * image allow
* 1st-party * allow
* 1st-party css allow
* 1st-party frame allow
* 1st-party image allow
i actually allow xhr on third-party requests once i enabled third-party requests, which makes it possible to "enable" a bunch of site with two clicks (popup panel then click on "all").