Replace upsidedown with mirror reflection
This commit is contained in:
parent
eee109117f
commit
3b134df77f
|
@ -0,0 +1,9 @@
|
|||
"""
|
||||
This script reflects all content passing through the proxy.
|
||||
"""
|
||||
from mitmproxy import http
|
||||
|
||||
|
||||
def response(flow: http.HTTPFlow) -> None:
|
||||
reflector = b"<style>body {transform: scaleX(-1);}</style></head>"
|
||||
flow.response.content = flow.response.content.replace(b"</head>", reflector)
|
|
@ -1,16 +0,0 @@
|
|||
"""
|
||||
This script rotates all images passing through the proxy by 180 degrees.
|
||||
"""
|
||||
import io
|
||||
from PIL import Image
|
||||
from mitmproxy import http
|
||||
|
||||
|
||||
def response(flow: http.HTTPFlow) -> None:
|
||||
if flow.response.headers.get("content-type", "").startswith("image"):
|
||||
s = io.BytesIO(flow.response.content)
|
||||
img = Image.open(s).rotate(180)
|
||||
s2 = io.BytesIO()
|
||||
img.save(s2, "png")
|
||||
flow.response.content = s2.getvalue()
|
||||
flow.response.headers["content-type"] = "image/png"
|
Loading…
Reference in New Issue