diff options
author | Lars-Dominik Braun <lars@6xq.net> | 2018-12-08 09:40:25 +0100 |
---|---|---|
committer | Lars-Dominik Braun <lars@6xq.net> | 2018-12-08 09:41:56 +0100 |
commit | 33fed291f230927c85c636287d87f99bbabf03d1 (patch) | |
tree | 5a4f757e7c0eff11a8ccf41e39f3a571accf1218 /crocoite | |
parent | 6ef9a981d02d545bd31534c987379534c8add999 (diff) | |
download | crocoite-33fed291f230927c85c636287d87f99bbabf03d1.tar.gz crocoite-33fed291f230927c85c636287d87f99bbabf03d1.tar.bz2 crocoite-33fed291f230927c85c636287d87f99bbabf03d1.zip |
behavior: Dump script options to file as well
click.js’s data was part of the script before
22adde79940d32c5f094f26f3e18b7160e7ccafc. Now it is injected
dynamically, but it still would be nice to have the data available.
Diffstat (limited to 'crocoite')
-rw-r--r-- | crocoite/behavior.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/crocoite/behavior.py b/crocoite/behavior.py index e731bcd..eb5478b 100644 --- a/crocoite/behavior.py +++ b/crocoite/behavior.py @@ -34,9 +34,8 @@ controller. This allows storing captured screenshots inside WARC files, for instance. """ -import asyncio +import asyncio, json, os.path from urllib.parse import urlsplit -import os.path from base64 import b64decode from collections import OrderedDict import pkg_resources @@ -66,9 +65,10 @@ class Script: return self.data @classmethod - def fromStr (cls, data): + def fromStr (cls, data, path=None): s = Script () s.data = data + s.path = path return s class Behavior: @@ -147,6 +147,8 @@ class JsOnload (Behavior): assert result.get ('subtype') != 'error', exception constructor = result['objectId'] + if self.options: + yield Script.fromStr (json.dumps (self.options, indent=2), '{}/options'.format (self.script.path)) result = await tab.Runtime.callFunctionOn ( functionDeclaration='function(options){return new this(options);}', objectId=constructor, |