add scriptmgr.py

This commit is contained in:
aozhiwei 2019-10-12 11:10:40 +08:00
parent 8cc62001fe
commit 94bed8db9f
2 changed files with 27 additions and 1 deletions

View File

@ -1,12 +1,29 @@
import os
import pychrome
os.environ['DEBUG'] = '1'
import scriptmgr
#os.environ['DEBUG'] = '1'
browser = pychrome.Browser(url="http://192.168.100.137:9223")
tab = browser.new_tab()
scriptmgr = scriptmgr.ScriptMgr(tab)
tab.start()
tab.call_method("Network.enable", maxPostDataSize=65536)
tab.call_method("Page.enable")
tab.call_method("Page.getResourceTree")
tab.call_method("Profiler.enable")
tab.call_method("Runtime.enable")
tab.call_method("Debugger.enable", maxScriptsCacheSzie=1000000)
tab.call_method("DOM.enable")
tab.call_method("CSS.enable")
tab.call_method("Overlay.enable")
tab.call_method("Log.enable")
tab.call_method("Page.navigate", url="http://localhost:7456/", _timeout=5)
while True:
cmdline= input('')
try:
msg = eval(cmdline)
except Exception as e:
print(e)

9
scripts/cdb/scriptmgr.py Normal file
View File

@ -0,0 +1,9 @@
class ScriptMgr:
def __init__(self, tab):
self.tab = tab
self.tab.set_listener('Debugger.scriptParsed', self.debuggerOnScriptParsed)
def debuggerOnScriptParsed(self, **kwargs):
print(kwargs)