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 🙏

© 2026 – Pkg Stats / Ryan Hefner

anti-debugger

v0.3.0

Published

Web反调试工具

Downloads

50

Readme

anti-debugger

Web反调试工具

安装

  • pnpm
$ pnpm add -D anti-debugger
  • yarn
$ yarn add -D anti-debugger
  • npm
$ npm install -D anti-debugger

使用

  • main.ts中引入并开启
import antiDebugger from 'anti-debugger'

antiDebugger()
  • 测试阶段可以屏蔽,推荐使用环境变量控制。
import antiDebugger from 'anti-debugger'

antiDebugger({
    /**
     * 轮询时间, 默认1000
     */
    // timeout: 1000,
    /**
     * 是否立即执行一次, 默认true
     */
    // immediate: true,
    /**
     * 是否开启deactivate breakpoints的判定条件, 默认100
     * 仅正数生效
     */
    // dbDiff: 100,
    /**
     * 是否输出开发日志
     */
    devLog: true,
    /**
     * 是否关闭debugger
     */
    deactivateDebugger: false,
    /**
     * localStorage中保存的是否关闭debugger key
     * 如果传递了该值,则在localStorage中读取该值
     * 如果该值为true,则关闭debugger
     * 如果该值为false,则检查deactivateDebugger,决定是否关闭debugger
     */
    // debuggerLocalStorageKey: 'ANTI-DEBUGGER',
})

提示 devLogdeactivateDebugger最好通过环境变量设置, 更多参数请自行查找。

警告 由于使用了eval,可能会收到如下提示:

Use of eval in "****" is strongly discouraged as it poses security risks and may cause issues with minification.

关闭反调试

需要停止反调试时(如 SPA 特定场景),调用destroy

import antiDebugger from 'anti-debugger'

antiDebugger()

// 停止反调试:停止轮询与探测、移除事件监听、重置状态
antiDebugger.destroy()

注意 destroy后事件监听不会自动恢复,需要重新初始化时请刷新页面。重复调用antiDebugger()会先清理上一轮运行状态再重新初始化。

版本

v0.3.0

  • 修复timeout配置未生效的问题(轮询间隔默认1000ms)。
  • 修复同步版generatorLoopimmediate行为与异步版不一致的问题。
  • 修复无限循环序列回绕判定(达到max即回绕)。
  • dbDiff默认值与文档对齐(100)。
  • 惩罚(跳转about:blank)改为立即执行,关闭"800ms内关闭DevTools取消惩罚"的竞态窗口。
  • 断点计时改用performance.now()并与Date.now()交叉验证,防御时间钩子篡改。
  • Undock(分离窗口)检测改为周期性探测(间隔2000/4000循环),覆盖页面加载一段时间后才打开的场景。
  • 性能探测连续两轮确认+绝对耗时下限(10ms)+console被hook时提高阈值,大幅降低误判。
  • 新增destroy()方法与重复初始化状态重置。

v0.2.0

  • 添加性能分析,判断Undock状态。
  • 优化检测模式,引入动态时间间隔检查。

v0.1.0

  • 实现基本的反调试功能