Search code examples
javascriptfiddler

fiddler custom rules script: oSession object is undeclared


I am trying to write some custom script for fiddler similar to this:

if (oSession.uriContains(".css")){
 oSession["ui-color"]="orange"; 
 oSession["ui-bold"]="true";
 oSession.oRequest.FailSession(404, "Blocked", "Fiddler blocked CSS file");
}

But I get compilation failure due to: Variable 'oSession' has not been declared. Has anyone ran into this problem before and managed to solve it?


Solution

  • Where did you put the code in question? Did you put it inside the BeforeRequest function? Did you change the name of the parameter in the function declaration?

    The declaration should look like this:

     static function OnBeforeRequest(oSession: Session) {
     // your code here...