cancel
Showing results for 
Search instead for 
Did you mean: 
btlyric
Level 12

Modify javascript referenced by base page

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...

0 Kudos
1 Reply
asabban
Level 17

Re: Modify javascript referenced by base page

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