1 Reply Latest reply on Oct 26, 2012 2:04 AM by asabban

    Modify javascript referenced by base page

    btlyric

      I want to modify a javascript file that is referenced by the base URL.

       

      The base page calls it with <script type="text/javascript" src="path/to/javascript-file.js"

       

      How can I extract that file, modify it, and put it back in the stream?

       

      I have already enabled HTML Opener and I can write that particular file to disk with Body.ToFile...

        • 1. Re: Modify javascript referenced by base page
          asabban

          Hello,

           

          you won´t be able to get the file back from disk into the rule engine. You should create a rule that triggers on "URL.Path equals path/to/javascript-file.js", so you have a rule that matches the java script file itself. Then you can use Events such as Body.Remove, Body.Replace and Bopy.Add to modify the script content. As an alternative you can use the HTML Opener and rewrite the path to point somewhere else, may a local web server, where you host a modified version of the script.

           

          Best,

          Andre