我可以成功运行下面的代码,但在混淆javascript-obfuscator
后失败。
const puppeteer = require('puppeteer-core');
let params = {
ignoreHTTPSErrors: true,
args: [
'--ignore-certificate-errors',
'--no-sandbox',
],
executablePath: this.chromePath,
headless: true,
};
const browser = await puppeteer.launch(params);
var page = await browser.newPage();
await page.goto(this.url, { waitUntil: 'load' });
await page.waitForTimeout(2000);
await page.content(); ----------------------- error in this line
await page.setViewport({ width: 1600, height: 1200 });
await page.waitForTimeout(2000);
错误信息:
(node:22648) UnhandledPromiseRejectionWarning: Error: Evaluation failed: ReferenceError: _0xa28d is not defined
at __puppeteer_evaluation_script__:1:21
at _0x1ce9f4._evaluateInternal (E:xxdistbundle.js:1:3355462)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at async _0x1ce9f4.evaluate (E:xxdistbundle.js:1:3353310)
at async _0x23b99f.content (E:xxdistbundle.js:1:3400665)
at async _0x14d154.content (E:xxdistbundle.js:1:3508435)
at async _0x571581.getContentInaSinglePage (E:xxdistbundle.js:1:4423286)
at async _0x508402.isInteresting (E:xxdistbundle.js:1:4622902)
at async _0x508402.startScan (E:xxdistbundle.js:1:4641280)
at async _0x421a37.scan (E:xxdistbundle.js:1:4643371)
at async E:xxdistbundle.js:1:4970734
这个问题的原因是什么,如何解决这个问题。任何建议吗?
有两种解决方案:
首先,你可以从外部传递变量,像这样:
形象另一种是将stringArray: true
禁用为stringArray: false
。
CLI命令:
javascript-obfuscator ./app.js --output ./app-obfuscated.js --string-array false
我认为这是javascript-obfuscator库的bug。作为替代方案,您可以使用以下包:
js-obfuscator
和木偶师配合得很好。