Skip to content

Instantly share code, notes, and snippets.

@wangbinyq
Forked from kylestev/JavaScript Injection
Created June 6, 2018 11:50
Show Gist options
  • Save wangbinyq/7302ed29757bf1e966fac0decbb1b856 to your computer and use it in GitHub Desktop.
Save wangbinyq/7302ed29757bf1e966fac0decbb1b856 to your computer and use it in GitHub Desktop.

Revisions

  1. @kylestev kylestev created this gist May 23, 2012.
    14 changes: 14 additions & 0 deletions JavaScript Injection
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    import Fiddler;

    class Handlers {
    static var injectJs = "<script>alert('I see you enjoy YouTube.')</script>";
    static var hostList = new HostList("*.youtube.com");

    static function OnBeforeResponse(oSession : Session) {
    // Filter to only HTML documents and on the domains we want
    if (hostList.ContainsHost(oSession.hostname) && oSession.oResponse.headers.ExistsAndContains("Content-Type", "text/html")) {
    oSession.utilDecodeResponse();
    oSession.utilReplaceInResponse('</head>', injectJs + '</head>');
    }
    }
    }