tidusx18
4/9/2018 - 7:17 PM

Compiling Puppeteer (Canvas Audit)

As of April 9, when compiling the Canvas audit script using npm "pkg", eval code does not work as intended due to it getting compiled. This is a temp fix if really needed.

REF: https://github.com/zeit/pkg/issues/204

I solved the problem with page.evaluate Error: Evaluation failed: SyntaxError: Unexpected identifier, just by putting evaluated code in a separate file, and configuring Pkg to not compile that file.

var eval = require('./eval');
frame.evaluate(eval.func1, arg1);
eval.js:

module.exports = {
    func1: function(arg1) {
        return document.querySelector(arg1)
    }
};
package.json:

"pkg": {
  "assets": "eval.js"
}