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

devtools-guard

v1.1.3

Published

A lightweight JavaScript library to detect and guard if browser DevTools are open, with customizable actions, framework support, and multiple detection strategies.

Readme


🚀 Features (v1.1.3)

  • 🔍 Detect when browser DevTools are open
  • 🕵️‍♂️ Multiple detection strategies:
    • Window size inspection
    • Console trap timing
    • debugger statement trap
    • Function.prototype.toString tampering
  • ⚡ Debounced detection to reduce false positives
  • 📣 onOpen and onClose event handlers
  • ⚙️ Configurable interval and detection strategies
  • 📦 Lightweight, framework-agnostic
  • 🧪 TypeScript support built-in

📦 Installation

npm install devtools-guard
# or
yarn add devtools-guard

✨ Usage

import { startDevtoolsDetector } from "devtools-guard"

startDevtoolsDetector({
  onOpen: ({ detectedBy }) => {
    alert(`DevTools is open! Detected via: ${detectedBy.join(", ")}`)
  },
  onClose: () => {
    console.log("DevTools closed ✅")
  },
  methods: ["dimensions", "console", "debugger", "toString"], // default: all
  interval: 500,
  debounceMs: 1000,
})

✅ Usage Notes

  • The console and debugger methods are browser-dependent and timing-sensitive.
  • You can selectively disable methods like:
startDevtoolsDetector({ methods: ["dimensions", "debugger"] })

🧪 Example (HTML)

<!DOCTYPE html>
<html>
  <head>
    <script type="module">
      import { startDevtoolsDetector } from "https://unpkg.com/devtools-guard?module"

      startDevtoolsDetector({
        onOpen: ({ detectedBy }) =>
          alert(`DevTools detected via: ${detectedBy.join(", ")}`),
        onClose: () => console.log("DevTools closed."),
      })
    </script>
  </head>
  <body>
    <h1>DevTools Detection Example</h1>
  </body>
</html>

⚙️ API

startDevtoolsDetector(options)

| Option | Type | Description | | ------------ | -------------------------------- | ---------------------------------------------------------------------------- | | onOpen | (res: DetectionResult) => void | Callback when DevTools are detected. | | onClose | () => void | Callback when DevTools are closed. | | interval | number | Polling interval in ms (default: 1000). | | debounceMs | number | Delay before triggering detection again (default: 500). | | methods | string[] | Methods used for detection: dimensions, console, debugger, toString. |


🧭 Branching Strategy

master
│
├── develop
│   ├── feature/v1.1-multi-method-detection
│   ├── feature/v1.2-event-emitter-api
│   ├── feature/v1.3-framework-hooks
│   └── ...
│
└── release/v2.0.0

| Branch | Purpose | | ------------------- | ---------------------------------------------------- | | master | ✅ Stable, published version | | develop | 🚧 Active development | | feature/* | 🌱 Feature branches (e.g., feature/v1.2-event-api) | | release/* | 🚀 Final staging for major version releases | | hotfix/* (opt.) | 🛠 Urgent patches directly merged to master |


⚙️ Initial Repo Setup

# Create develop from master
git checkout master
git checkout -b develop

# Start your first feature branch
git checkout -b feature/v1.1-multi-method-detection develop

🛣️ Roadmap Highlights

| Version | Highlights | | -------- | -------------------------------------------------------------- | | v1.1.0 | ✅ Multi-method detection, debounce, strategy config | | v1.2.0 | 🔌 EventEmitter support, on('open'), off(), etc. | | v1.3.0 | 🔧 React/Vue/Svelte composables/hooks | | v2.0.0 | 🧱 Obfuscation resistance, headless detection, multiple builds | | v2.1.0 | 📈 Analytics dashboard (optional, opt-in) |

See full roadmap → ROADMAP.md


💡 Use Cases

  • Prevent cheating in browser-based games
  • Detect inspection attempts in client-side SaaS/web apps
  • Log or alert when sensitive code is at risk
  • Automatically logout users or restrict actions
  • In future: detect headless automation environments

📁 Project Structure

devtools-guard/
├── src/                # Core detection logic
├── dist/               # ESM and UMD bundles
├── examples/           # Live HTML demos
├── tests/              # Unit tests (WIP)
├── README.md
├── ROADMAP.md
├── LICENSE
└── package.json

🧑‍💻 Contributing

Pull requests, issues, and feedback are welcome!

  1. Fork this repo
  2. Create your feature branch (git checkout -b feature/something)
  3. Commit your changes (git commit -m 'feat: add something')
  4. Push and open a PR 🎉

📃 License

MIT © 2025 DicksonPaL21


📣 Feedback

Have ideas or feedback? Open an issue or reach out—let's make DevTools detection better for everyone.