demo/extend/custom.js
function addExtendSize(Nightmare, opts) {
    Nightmare.action('size', function (done) {
        console.log('size opts', opts);

        this.evaluate_now(() => {
            const w = Math.max(
                document.documentElement.clientWidth,
                window.innerWidth || 0
            );
            const h = Math.max(
                document.documentElement.clientHeight,
                window.innerHeight || 0
            );
            return {
                height: h,
                width: w
            };
        }, done);
    });
}
function addExtendSize(Nightmare, opts) {
    Nightmare.action('size', function (done) {
        console.log('size opts', opts);

        this.evaluate_now(() => {
            const w = Math.max(
                document.documentElement.clientWidth,
                window.innerWidth || 0
            );
            const h = Math.max(
                document.documentElement.clientHeight,
                window.innerHeight || 0
            );
            return {
                height: h,
                width: w
            };
        }, done);
    });
}
自定义扩展函数： 获得视窗大小