Skip to content

Instantly share code, notes, and snippets.

@vimagick
Created May 29, 2014 05:53
Show Gist options
  • Save vimagick/3f5acbb1081937a51f10 to your computer and use it in GitHub Desktop.
Save vimagick/3f5acbb1081937a51f10 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
# mitmproxy script to turn images upside down
def contains(x, y):
return any(y in i for i in x)
def request(content, flow):
hd = flow.request.headers
if 'Accept-Encoding' in hd and contains(hd['Accept'], 'text/html'):
del hd['Accept-Encoding']
def response(context, flow):
hd = flow.response.headers
if 'Content-Encoding' not in hd and contains(hd['Content-Type'], 'text/html'):
flow.response.content = flow.response.content.replace(
'</head>',
'<style>img {transform:rotate(180deg) !important;}</style></head>'
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment