New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

block-inspect

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

block-inspect

A simple JavaScript utility to deter users from opening browser developer tools (inspect element) and disable context menus, selection, and copy/paste on a website.

latest
Source
npmnpm
Version
1.3.1
Version published
Maintainers
1
Created
Source

block-inspect

A lightweight, zero-dependency JavaScript utility to deter users from inspecting your website using browser developer tools, right-click, or clipboard interactions.

⚠️ Note: Possible to bypass this using advanced measures.

Features

  • ❌ Disable right-click context menu
  • ❌ Block DevTools shortcuts (F12, Ctrl+Shift+I/J/U, Cmd+Opt+I/J/U, etc.)
  • ❌ Optional: Block copy, cut, paste
  • ❌ Optional: Disable text selection
  • 🔁 New: Redirect page if DevTools are opened (URL or "back")
  • ✅ Optional callback on inspection attempts
  • ✅ Whitelist specific key combos (e.g., "Ctrl+R" for refresh)
  • ✅ Dynamic enable/disable
  • ✅ No dependencies

Installation

npm install block-inspect

Usage

ES Modules

import blockInspect from 'block-inspect';

// Default
blockInspect();

// Custom options
blockInspect({
  disableContextMenu: true,
  disableDevToolsShortcut: true,
  disableSelection: true,
  disableCopy: true,
  disableCut: true,
  disablePaste: true,
  allowedKeys: ['Ctrl+R', 'Meta+R', 'F5'],
  onInspectAttempt: () => {
    alert('Inspect attempt blocked!');
  },
  // Redirect if DevTools open or shortcut is blocked:
  // - Use a URL to redirect to another page
  // - Or use "back" to navigate to previous page
  redirectOnInspect: 'https://example.com/warning.html'
  // redirectOnInspect: 'back',
});

Stop, Resume, Update

blockInspect.stop(); // Disable
blockInspect.isActive(); // Check status
blockInspect.updateOptions({ disablePaste: false }); // Modify while active

Keywords

inspect

FAQs

Package last updated on 19 May 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts