Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Hide CSS files of Fiddler tracif
// Open Fiddler and Choose "Rules" menu, click "Customize Rules..." and add this code to CustomRule.js
class Handlers
{
// ....
public static RulesOption("Hide CSS")
BindPref("fiddlerscript.rules.HideCSS")
var m_HideCSS: boolean = false;
// ....
static function OnBeforeResponse(oSession: Session) {
// ....
if (m_HideCSS && oSession.oResponse.headers.ExistsAndContains("Content-Type", "text/css") )
{
oSession["ui-hide"] = "true";
}
// ....
}
}
@huseyint

This comment has been minimized.

Copy link

huseyint commented Feb 25, 2016

And for JavaScript files:

class Handlers
{
    // ....
    public static RulesOption("Hide JavaScript")
    BindPref("fiddlerscript.rules.HideJS")
    var m_HideJS: boolean = false;
    // ....
    static function OnBeforeResponse(oSession: Session) {
        // ....
        if (m_HideJS && (oSession.oResponse.headers.ExistsAndContains("Content-Type", "text/javascript") || oSession.oResponse.headers.ExistsAndContains("Content-Type", "application/x-javascript") || oSession.oResponse.headers.ExistsAndContains("Content-Type", "application/javascript")))
        {
            oSession["ui-hide"] = "true";
        }
            // ....
    }
}
@heldersepu

This comment has been minimized.

Copy link

heldersepu commented Mar 16, 2016

Great additions!
Both should be integrated into default Fiddler install ...

@poma

This comment has been minimized.

Copy link

poma commented May 22, 2016

You may also want to exclude ajax when filtering JS:

        if (m_HideJS && !oSession.oRequest.headers.ExistsAndContains("X-Requested-With", "XMLHttpRequest") && (oSession.oResponse.headers.ExistsAndContains("Content-Type", "text/javascript") || oSession.oResponse.headers.ExistsAndContains("Content-Type", "application/x-javascript") || oSession.oResponse.headers.ExistsAndContains("Content-Type", "application/javascript")))
        {
            oSession["ui-hide"] = "true";
        }

maybe also add filter for .js file extensions since some websites may include static js files with ajax

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.