lib/capturejs.js
function manipulatePage(page) {
        if (DEBUG && !page.phantom) inspectArgs("manipulatePage: ", page);

        if (timer !== undefined) {
            clearTimeout(timer);
        }

        // Inject an external script file.
        if (option["javascript-file"]) {
            page.injectJs(option["javascript-file"]);
        }

        // Inject an in-line script from the command line.
        if (option["inject-script"]) {
            var injectScript = option["inject-script"];
            injectScript = (typeof injectScript === "function") ?
                injectScript.toString() : `function() { ${injectScript} }`;
            page.evaluateJavaScript(injectScript);
        }

        if (option.waitcapturedelay) {
            setTimeout(function () { return page }, +option.waitcapturedelay);
        } else {
            return page;
        }
    }
function manipulatePage(page) {
        if (DEBUG && !page.phantom) inspectArgs("manipulatePage: ", page);

        if (timer !== undefined) {
            clearTimeout(timer);
        }

        // Inject an external script file.
        if (option["javascript-file"]) {
            page.injectJs(option["javascript-file"]);
        }

        // Inject an in-line script from the command line.
        if (option["inject-script"]) {
            var injectScript = option["inject-script"];
            injectScript = (typeof injectScript === "function") ?
                injectScript.toString() : `function() { ${injectScript} }`;
            page.evaluateJavaScript(injectScript);
        }

        if (option.waitcapturedelay) {
            setTimeout(function () { return page }, +option.waitcapturedelay);
        } else {
            return page;
        }
    }
function manipulatePage ( page ) { if ( DEBUG && ! page . phantom ) inspectArgs ( "manipulatePage: " , page ) ; if ( timer !== undefined ) { clearTimeout ( timer ) ; } // Inject an external script file. if ( option [ "javascript-file" ] ) { page . injectJs ( option [ "javascript-file" ] ) ; } // Inject an in-line script from the command line. if ( option [ "inject-script" ] ) { var injectScript = option [ "inject-script" ] ; injectScript = ( typeof injectScript === "function" ) ? injectScript . toString ( ) : ` ${ injectScript } ` ; page . evaluateJavaScript ( injectScript ) ; } if ( option . waitcapturedelay ) { setTimeout ( function ( ) { return page } , + option . waitcapturedelay ) ; } else { return page ; } }
Inject JavaScript into the open page.
Inject JavaScript into the open page .