var esprima = require('esprima')
var escodegen = require('escodegen')
content = "function _0x355d23(_0x450614) {
if (('' + _0x450614 / _0x450614)[_0x55f3('0x1c', 'x56x32x4bx45')] !== 0x1 || _0x450614 % 0x14 === 0x0) {
(function() {}
[_0x55f3('0x1d', 'x43x4ex55x59')]((undefined + '')[0x2] + (!![] + '')[0x3] + ([][_0x55f3('0x1e', 'x77x38x50x52')]() + '')[0x2] + (undefined + '')[0x0] + (![] + [0x0] + String)[0x14] + (![] + [0x0] + String)[0x14] + (!![] + '')[0x3] + (!![] + '')[0x1])());
} else {
(function() {}
['x63x6fx6ex73x74x72x75x63x74x6fx72']((undefined + '')[0x2] + (!![] + '')[0x3] + ([][_0x55f3('0x1f', 'x4cx24x28x44')]() + '')[0x2] + (undefined + '')[0x0] + (![] + [0x0] + String)[0x14] + (![] + [0x0] + String)[0x14] + (!![] + '')[0x3] + (!![] + '')[0x1])());
}
_0x355d23(++_0x450614);
}"
function formatJS(){ //context是要格式的js
var ast=esprima.parseScript(content.toString());
var ast_to_json=JSON.stringify(ast);
console.log(ast_to_json);
var ast1=JSON.parse(ast_to_json);
var code=escodegen.generate(ast1);
console.log(code);
return code;
}
formatJS()
在线生成AST语法树
http://esprima.org/demo/parse.html