// PhantomJS setup var webPage = require('webpage'); var page = webPage.create(); var system = require('system'); var waitForMath; var noLongerExecWaitForMathJax = false; // Usage if (system.args.length < 2) { console.log("Usage: phantomjs render-math-and-dump.js "); console.log("Renders and dumps the DOM to the console."); phantom.exit(); }; // Open the page and on success set the window interval function // Alternatives: // page.open(encodeURI(system.args[1]), function(status) { // page.open("file://" + encodeURI(system.args[1]), function(status) { page.open(system.args[1], function(status) { if (status === "success") { // Execute the query every 20ms waitForMath = window.setInterval( waitForMathJax, 20 ); }; }); // This also works (to some extent) with web URLs. // page.open(system.args[1], function(status){ // if (status === "success") { // // In this setup a complete local MathJax installation // // is present in MathJax/ // page.injectJs("MathJax/MathJax.js"); // page.injectJs("ConfigMathJax.js"); // // Execute the query every 20ms // waitForMath = window.setInterval( // waitForMathJax, // 20 // ); // }; // }); // Removes all MathJax