Skip to content

Instantly share code, notes, and snippets.

@xsbchen
Forked from kylestev/JavaScript Injection
Created November 19, 2013 02:34
Show Gist options
  • Select an option

  • Save xsbchen/7539312 to your computer and use it in GitHub Desktop.

Select an option

Save xsbchen/7539312 to your computer and use it in GitHub Desktop.
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>');
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment