Skip to content
Fetching contributors…
Cannot retrieve contributors at this time
24 lines (18 sloc) 739 Bytes
# Use 'page.injectJs()' to load the script itself in the Page context
if phantom?
page = require('webpage').create()
# Route "console.log()" calls from within the Page context to the main
# Phantom context (i.e. current "this")
page.onConsoleMessage = (msg) -> console.log(msg)
page.onAlert = (msg) -> console.log(msg)
console.log "* Script running in the Phantom context."
console.log "* Script will 'inject' itself in a page..." "about:blank", (status) ->
if status is "success"
if page.injectJs("")
console.log "... done injecting itself!"
console.log "... fail! Check the $PWD?!"
alert "* Script running in the Page context."
Jump to Line
Something went wrong with that request. Please try again.