How to inject a piece of JS code into an 3rd party web page?


I am trying to do some POC of client side utilities for a 3rd party web page. I want to inject a piece of my experimental JS into that page. But I don’t have access to the target page. Is there any way to do it?


Ideally, I want to do it with IE 10.
And I want to place the JS file locally on my disk, and have it loaded automatically.


Just found one related thread: Injecting JavaScript into head element of website using Fiddler


Maybe I didn’t describe my question clear enough so many people think this cannot be done.

Inspired by this thread: Injecting JavaScript into head element of website using Fiddler, it turns out I can use FiddlerScript to achieve this.

Steps are:

  1. Set the oSession.bBufferResponse = true; in OnBeforeRequest()
    method so Fiddler proxy has a chance to buffer and modify the

  2. Then modify the response as I want in OnBeforeResponse() method, where I can inject my JS into the response DOM.

For details: check the book < Debugging with Fiddler > by Eric Lawrence, chapter ‘FiddlerScript

Answered By – smwikipedia

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published