Intercept an HTTP request at browser end to alter some html content

后端 未结 11 1704
灰色年华
灰色年华 2021-02-06 19:43

I would like to do as follows. What would be the best way? A general answer will also be fine.

I would like to intercept an HTTP request at the client end to alter some

11条回答
  •  不知归路
    2021-02-06 19:55

    Such an approach is the least efficient method of doing what you want to achieve.

    If this is a client side application, the client may disable it and thus render it useless. It is also hard to maintain and requires more complex programming to ensure that it works with SSL.

    • If using a browser plugin, or toolbar, it would need to be made for a specific browser.
    • If using a listening server to intercept the HTTP request, this provides complexity and difficulty when the content is encrypted, also unnecessary overhead.
    • If using a local proxy (meaning that the client's browser needs to point to a local proxy service), maybe the most effective client side method, but still have the disadvantages mentioned above (hard to maintain etc.)

    I believe that what you are looking to do is completely reinventing the wheel.

    The fact that you have offered a bounty begs the question that you indeed need to do this in C# and client side, but 'censoring bad things' means you need to prohibit content, and any client side method would eventually give the power to the client to remove this limitation.

    Personally, I have had great success with Squid and it's content adaptation features.

    This means, that the clients need to have a controlled Internet source. Meaning that, if they are all in a LAN and sharing a common Internet gateway, this is easily feasible if you have spare a server to act as a proxy.

    I recommend you get a small linux box, which can have a simple Ubuntu Server Edition, then add Squid. The net is full of tutorials, but the level of implementation has become easy enough to do even without them.

    I may have gone completely off-topic, but I hope I could assist.

提交回复
热议问题