npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

pay-api

v1.1.0

Published

这是一个功能强大的JavaScript代码压缩和混淆工具,支持多种压缩级别和混淆强度,可以有效保护你的JavaScript代码。

Downloads

31

Readme

JavaScript代码压缩和混淆工具

这是一个功能强大的JavaScript代码压缩和混淆工具,支持多种压缩级别和混淆强度,可以有效保护你的JavaScript代码。

功能特性

  • 代码压缩: 使用Terser进行高效的代码压缩
  • 代码混淆: 使用javascript-obfuscator进行代码混淆保护
  • 多级混淆: 支持轻度、中度、重度三种混淆级别
  • 批量处理: 支持单个文件和批量文件处理
  • 详细统计: 显示压缩前后的文件大小和压缩率
  • 错误处理: 完善的错误处理和提示信息

安装依赖

npm install

工具说明

1. 压缩工具 (compress-tool.js)

基础的压缩工具,支持标准压缩和高级压缩配置。

使用方法:

node compress-tool.js <输入文件> <输出文件> [选项]

选项:

  • --obfuscate <级别>: 启用混淆功能,级别: light(轻度), medium(中度), heavy(重度)
  • --advanced: 使用高级压缩配置
  • --help: 显示帮助信息

示例:

# 标准压缩
node compress-tool.js src/video.js dist/video.min.js

# 压缩+中度混淆
node compress-tool.js src/video.js dist/video.obfuscated.js --obfuscate medium

# 压缩+重度混淆
node compress-tool.js src/video.js dist/video.heavy.js --obfuscate heavy

# 高级压缩
node compress-tool.js src/video.js dist/video.advanced.js --advanced

2. 专业混淆工具 (obfuscate-tool.js)

专业的代码混淆工具,提供更强大的混淆功能。

使用方法:

node obfuscate-tool.js <输入文件> <输出文件> [选项]

选项:

  • --level <级别>: 混淆级别: light(轻度), medium(中度), heavy(重度) [默认: medium]
  • --report: 生成处理报告
  • --help: 显示帮助信息

示例:

# 中度混淆 (默认)
node obfuscate-tool.js src/video.js dist/video.obfuscated.js

# 重度混淆
node obfuscate-tool.js src/video.js dist/video.heavy.js --level heavy

# 轻度混淆 + 生成报告
node obfuscate-tool.js src/video.js dist/video.light.js --level light --report

混淆级别说明

轻度混淆 (light)

  • 基础标识符混淆
  • 字符串数组化
  • 禁用console输出
  • 处理速度快,文件大小适中

中度混淆 (medium) - 推荐

  • 控制流平坦化
  • 死代码注入
  • 调试保护
  • 字符串编码 (base64)
  • 平衡保护与性能

重度混淆 (heavy)

  • 最大保护级别
  • 全局变量重命名
  • 属性重命名
  • 多种字符串编码 (base64 + rc4)
  • 自我保护机制
  • 可能影响性能

混淆功能详解

代码混淆特性

  • 标识符混淆: 将变量名、函数名等替换为无意义的短名称
  • 控制流平坦化: 改变代码执行流程,增加逆向分析难度
  • 死代码注入: 注入无用的代码片段
  • 字符串编码: 对字符串进行base64或rc4编码
  • 调试保护: 检测并阻止调试器
  • 自我保护: 检测代码完整性,防止篡改

压缩特性

  • 删除注释: 移除所有注释
  • 删除空白: 移除不必要的空格和换行
  • 变量名缩短: 缩短变量名
  • 删除死代码: 移除未使用的代码
  • 常量折叠: 计算常量表达式

处理结果示例

JavaScript代码混淆工具
======================
开始混淆文件: src/video.js
混淆级别: medium
步骤1: 执行JavaScript混淆...
步骤2: 执行代码压缩...

处理完成!
原始大小: 3750 字节
混淆后大小: 21034 字节
最终大小: 10347 字节
总体压缩率: -175.92%
输出文件: dist/video.obfuscated.js

注意事项

  1. 性能影响: 重度混淆可能会影响代码执行性能
  2. 兼容性: 混淆后的代码可能与某些调试工具不兼容
  3. 备份: 建议在处理前备份原始文件
  4. 测试: 混淆后请充分测试代码功能是否正常

文件结构

pay/
├── src/
│   └── video.js          # 原始源代码
├── dist/
│   ├── video.light.js    # 轻度混淆结果
│   ├── video.obfuscated.js # 中度混淆结果
│   └── video.heavy.js    # 重度混淆结果
├── compress-tool.js      # 压缩工具
├── obfuscate-tool.js     # 混淆工具
├── package.json          # 项目配置
└── README.md            # 说明文档

技术栈

  • Terser: JavaScript压缩器
  • javascript-obfuscator: JavaScript混淆器
  • Node.js: 运行环境

许可证

MIT License