Détail du package

@comptechco/disable-devtool

imad.bakir20ISC0.0.3

Disable web developer tools from the f12 button, right-click and browser

comptechco, comptechco-disable-devtool

readme

@comptechco/disable-devtool

This package helps in disabling developer tools on browsers, preventing users from inspecting or modifying the web page's content through dev tools.

Installation

If not using Jenkins:

Install the package using the following command:

npm install @comptechco/disable-devtool --//registry.npmjs.org/:_authToken=ComptechcoToken

If using Jenkins:

  1. Add the following entry to your package.json:
"@comptechco/disable-devtool": "version"
  1. Create a .npmrc file in the root of your project and add the following content:
//registry.npmjs.org/:_authToken=ComptechcoToken
  1. Run the following command to install the package:
npm i

Usage

Import the package and use it as follows:

import disableDevtool from "@comptechco/disable-devtool";

disableDevtool({
  disableMenu: false,
  url: "assets/html/yourhtmlpage.html",
});

Configuration

You can pass an options object to customize the behavior of the package. Below are the available options:

declare interface IConfig {
  md5?: string; // Bypass disabled MD5 value, bypass disabled by default
  url?: string; // Jump page when closing the page fails, the default value is localhost
  tkName?: string; // Bypass URL parameter name when disabled, default is ddtk
  ondevtoolopen?(type: DetectorType, next: Function): void; // Callback for opening the developer panel
  ondevtoolclose?(): void; // Callback for developer panel close
  interval?: number; // Timer interval, default is 200ms
  disableMenu?: boolean; // Whether to disable the right-click menu, default is true
  stopIntervalTime?: number; // Waiting time to cancel monitoring on mobile
  clearIntervalWhenDevOpenTrigger?: boolean; // Whether to stop monitoring after triggering, default is false
  detectors?: Array<DetectorType>; // Enabled detectors. The default is all, it is recommended to use all
  clearLog?: boolean; // Whether to clear the log every time
  disableSelect?: boolean; // Whether to disable text selection, default is false
  disableCopy?: boolean; // Whether to disable copying, default is false
  disableCut?: boolean; // Whether to disable cutting, default is false
  disablePaste?: boolean; // Whether to disable pasting, default is false
  ignore?: (string | RegExp)[] | null | (() => boolean); // Conditions to ignore the disablement
  disableIframeParents?: boolean; // Whether all parent windows are disabled in the iframe
  timeOutUrl?: string; // URL to forward when the page timeout occurs
  rewriteHTML?: string; // HTML page to rewrite after opening the dev tools
}

DetectorType Enum

enum DetectorType {
  Unknown = -1,
  RegToString = 0, // Check based on regular expression
  DefineId, // Detect based on DOM id
  Size, // Detect based on window size (this probe is not enabled by default)
  DateToString, // Check based on Date.toString
  FuncToString, // Check based on Function.toString
  Debugger, // Detect breakpoints (valid only for iOS Chrome on real devices)
  Performance, // Performance detection based on log big data
  DebugLib, // Detect third-party debugging tools (e.g., eruda, vconsole)
}

License

MIT