First few behaviors

This commit is contained in:
Eldon 2014-02-13 01:00:39 -05:00
parent fe1c68af90
commit 445288d5e7
3 changed files with 59 additions and 6 deletions

13
umbra/behaviors.py Normal file
View file

@ -0,0 +1,13 @@
from json import dumps, load
from time import sleep
import os, re
behaviors_file = os.path.sep.join(__file__.split(os.path.sep)[:-1] + ['behaviors.json'])
def execute(url, ws, command_id):
sleep(5)
with open(behaviors_file) as js:
behaviors = load(js)
for behavior in behaviors:
if re.match(behavior['site'], url):
for script in behavior['scripts']:
ws.send(dumps(dict(method="Runtime.evaluate", params={"expression": script}, id=next(command_id))))