diff options
author | Aldo Cortesi <aldo@corte.si> | 2017-04-26 11:23:48 +1200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-26 11:23:48 +1200 |
commit | 1daf0b3f0ae80e1e2dce823204547611e28d6ee9 (patch) | |
tree | 57b4153fa4980e2af1aff7aae9c84ae507a463fb /examples/simple/modify_body_inject_iframe.py | |
parent | 02c82b1b602b7d5ab03c1e25d7d89f44c593174a (diff) | |
parent | b72f1390937e9799f588fd9a1564056131fb1aa7 (diff) | |
download | mitmproxy-1daf0b3f0ae80e1e2dce823204547611e28d6ee9.tar.gz mitmproxy-1daf0b3f0ae80e1e2dce823204547611e28d6ee9.tar.bz2 mitmproxy-1daf0b3f0ae80e1e2dce823204547611e28d6ee9.zip |
Merge pull request #2264 from cortesi/options
Change the way addons handle options
Diffstat (limited to 'examples/simple/modify_body_inject_iframe.py')
-rw-r--r-- | examples/simple/modify_body_inject_iframe.py | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/examples/simple/modify_body_inject_iframe.py b/examples/simple/modify_body_inject_iframe.py index d54468d2..dff72afa 100644 --- a/examples/simple/modify_body_inject_iframe.py +++ b/examples/simple/modify_body_inject_iframe.py @@ -1,26 +1,21 @@ # (this script works best with --anticache) from bs4 import BeautifulSoup +from mitmproxy import ctx class Injector: - def __init__(self): - self.iframe_url = None - def load(self, loader): loader.add_option( "iframe", str, "", "IFrame to inject" ) - def configure(self, options, updated): - self.iframe_url = options.iframe - def response(self, flow): - if self.iframe_url: + if ctx.options.iframe: html = BeautifulSoup(flow.response.content, "html.parser") if html.body: iframe = html.new_tag( "iframe", - src=self.iframe_url, + src=ctx.options.iframe, frameborder=0, height=0, width=0) |