Then we identify those areas we don’t want to be displayed by inspecting the rendered HTML. In my case I use Firebug to help me with this:


Now we start Fiddler and go to the Rules menu and select the Customize Rules option (Ctrl + R).

The CustomRules.js file will open (typically in Notepad) and we can start editing it. If we want to use another text editor we can go to the C:\Users\[USER]\Documents\Fiddler2\Scripts folder and open it from there.

Once opened, we search for the OnBeforeResponse function and we make our changes there by using the utilReplaceInResponse() method. Following are the replaces necessary to the HTML response so that the browser doesn’t show the ads and other elements we don’t want to be displayed.

Highlighted code:
static function OnBeforeResponse(oSession: Session) {
...
if (oSession.HostnameIs("stackoverflow.com") && oSession.oResponse.headers.ExistsAndContains("Content-Type","text/html")){
oSession.utilDecodeResponse();
oSession.utilReplaceInResponse('<div class="nav askquestion">','<div class="nav askquestion" style="display: none;">');
oSession.utilReplaceInResponse('<div class="everyonelovesstackoverflow">','<div class="everyonelovesstackoverflow" style="display: none;">');
oSession.utilReplaceInResponse('<div id="footer">','<div id="footer" style="display: none;">');
oSession.utilReplaceInResponse('<form id="post-form"', '<form id="post-form" style="display: none;"');
oSession.utilReplaceInResponse('<div id="sidebar">', '<div id="sidebar" style="display: none;">');
}
}
Once this is done, we save the file and refresh the page. The elements we don’t want to be displayed will be hidden thanks to the HTML replaces in the rules file.
Following is the final result:
