Sha256: 7bdd074c194b7ed3fe431d87018c8dd8fe1d1a85f57ec1f168c7163de6b1f91b

Contents?: true

Size: 1.25 KB

Versions: 1

Compression:

Stored size: 1.25 KB

Contents

"use strict";
var system  = require('system'),
    page    = require('webpage').create(),
    address = system.args[1], //tmp file of the html to be processed
    no_script = system.args[2] == "true",
    include = system.args[3], //tmp file for the injected js file
    timeout = parseInt(system.args[4]) || 1000, //return page contents after a timeout
    wait_event = system.args[5]; //return page contents after an event

//write out to console to export contents
//and get out of here
function finish(){
  console.log(page.content); 
  phantom.exit(); 
}
 
page.onLoadFinished = function(status){
  //catch wait_event
  page.onCallback = finish
  page.evaluate(function(finish, wait_event) {
    document.addEventListener(wait_event, window.callPhantom, false)
  }, finish, wait_event)
  //clear script tags
  if(no_script) {
    page.evaluate(function(){
      var script_tags = document.getElementsByTagName("script");
      for(var i = 0; i < script_tags.length; i++) {
        script_tags[i].parentNode.removeChild(script_tags[i]);
      }
    })
  }
  //load included scripts to be loaded on the dom
  if(!!include){
    page.injectJs(include);
  }
  if(timeout > 0){
    setTimeout(finish, timeout);//timout to bailout after a period
  }
};

page.open("file://"+address)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ghost_in_the_post-0.0.2 lib/ghost_in_the_post/phantom/staticize.js