unminify
Version 2.0.0
一个小项目,可以撤消JavaScript构建工具对JavaScript做出的可怕的几件事。除了撤消大多数缩小外,它还逆转了野外使用的一些愚蠢但令人惊讶的“混淆”技术。
我可能会尝试一下,例如,我发现的这片javascript随机。
npm install -g unminify
或在不通过npx安装的情况下使用它(自npm 5.2.0以来可用)
npx unminify [...args]
unminify /path/to/file.js
--safety可以根据用户的要求安全保证来启用/禁用转换。有关更多详细信息,请参阅安全级文档。 --safety的价值可能是uselesssafe (默认)mostly-safeunsafewildly-unsafe--additional-transform零次或更多次,每个次接下来是通往模块提供AST变换的路径;函数信号表明未通过返回其输入来应用转换 let { unminifySource } = require ( 'unminify' ) ;
let sourceText = '/* a minified/"obfuscated" JavaScript program */' ;
console . log ( unminify ( sourceText ) ) ;
// or, with options
console . log ( unminifySource ( sourceText , {
safety : unminify . safetyLevels . UNSAFE ,
additionalTransforms : [ function ( ast ) { /* ... */ } ] ,
} ) ) ;如果您已经有了一棵Shift树,则可以使用unminifyTree避免使用Codegen和Reparse成本。
let { parseScript } = require ( 'shift-parser' ) ;
let { unminifyTree } = require ( 'unminify' ) ;
let sourceText = '/* a minified/"obfuscated" JavaScript program */' ;
let tree = parseScript ( sourceText ) ;
let unminifiedTree = unminifyTree ( tree ) ; Copyright 2017 Shape Security, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.