Skip to content

Commit

Permalink
Optionally execute some JS on window load.
Browse files Browse the repository at this point in the history
  • Loading branch information
georgebrock committed Oct 29, 2011
1 parent 9c4265a commit 6d57953
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions webkit2png
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ class WebkitLoad (Foundation.NSObject, WebKit.protocols.WebFrameLoadDelegate):
def webView_didFinishLoadForFrame_(self,webview,frame):
# don't care about subframes
if (frame == webview.mainFrame()):
if self.options.js:
scriptobject = webview.windowScriptObject()
scriptobject.evaluateWebScript_(self.options.js)
Foundation.NSTimer.scheduledTimerWithTimeInterval_target_selector_userInfo_repeats_( self.options.delay, self, self.doGrab, webview, False)

def doGrab(self,timer):
Expand Down Expand Up @@ -225,6 +228,8 @@ examples:
help="don't load images")
cmdparser.add_option("--debug", action="store_true",
help=optparse.SUPPRESS_HELP)
cmdparser.add_option("--js", type="string", default=None,
help="JavaScript to execute when the window finishes loading")
(options, args) = cmdparser.parse_args()
if len(args) == 0:
cmdparser.print_usage()
Expand Down

0 comments on commit 6d57953

Please sign in to comment.