ä¸æ–‡ | Online Trial | Changelog | Gitee | Message Board | QQ Group: 720626970
npm i disable-devtool
import DisableDevtool from 'disable-devtool';
DisableDevtool();
<script disable-devtool-auto src='https://cdn.jsdelivr.net/npm/disable-devtool'></script>
Or cite by version:
<!--Use the specified version-->
<script disable-devtool-auto src='https://cdn.jsdelivr.net/npm/disable-devtool@x.x.x'></script>
<!--Use latest version-->
<script disable-devtool-auto src='https://cdn.jsdelivr.net/npm/disable-devtool@latest'></script>
disable-devtool disables all access to the devtools, preventing 'code porting' via the devtools
The library has the following features:
It is recommended to use this method of installation and use, and the script script can be intercepted by the agent separately and cannot be executed
install disable-devtool
npm i disable-devtool
import DisableDevtool from 'disable-devtool';
DisableDevtool(options);
Return value DisableDevtool The return value is of the following type
interface IDDResult {
success: boolean; Indicates whether it is enabled normally
reason: string; The reason why it was not properly enabled
}
The parameters and descriptions in options are as follows:
declare interface IConfig {
md5?: string; // bypass disabled md5 value, see 3.2 for details, 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; // The callback for opening the developer panel, the url parameter is invalid when enabled, the type is monitoring mode, see 3.5 for details, the next function is to close the current window
ondevtoolclose?(): void; // callback for developer panel close
interval?: number; // timer interval default 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 the default is false, this parameter is invalid when using ondevtoolclose
detectors?: Array<DetectorType>; // Enabled detectors See 3.5 for details of 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 selection text 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 paste, default is false
ignore?: (string| RegExp)[] | null | (()=>boolean); // Some cases ignore the disablement
disableIframeParents?: boolean; // Whether all parent windows are disabled in the iframe
timeOutUrl?: string; // Turn off URLs that page timeouts forward towards
rewriteHTML?: string; // Detecting the rewriting page after opening
}
enum DetectorType {
Unknown = -1,
RegToString = 0, // Check according to regular
DefineId, // detect based on dom id
Size, // Detect based on window size // After version 0.3.5, this probe is not enabled by default
DateToString, // check against Date.toString
FuncToString, // check according to Function.toString
Debugger, // According to breakpoint detection, it is only valid in the case of ios chrome real machine
Performance, // Performance detection based on log big data
DebugLib, // Detect third-party debugging tools eruda and vconsole
};
The way in which the key is used in conjunction with md5 in this library allows developers to bypass the ban online.
The process is as follows:
First specify a key a (the value should not be recorded in the code), use md5 encryption to obtain a value b, and pass in b as the md5 parameter. When accessing the url, the developer only needs to bring the url parameter ddtk=a, then you can Bypass disable.
The disableDevtool object exposes the md5 method, which can be used by developers when encrypting:
DisableDevtool.md5('xxx');
<script
disable-devtool-auto
src='https://cdn.jsdelivr.net/npm/disable-devtool'
md5='xxx'
url='xxx'
tk-name='xxx'
interval='xxx'
disable-menu='xxx'
detectors='xxx'
clear-log='true'
disable-select='true'
disable-copy='true'
disable-cut='true'
disable-paste='true'
></script>
Note:
disable-devtool-auto
property when configuring the property<script src='https://cdn.jsdelivr.net/npm/disable-devtool'></script>
<script>
DisableDevtool({
// The parameters are the same as in 3.1
})
</script>
Disable-Devtool has the following monitoring modes, DisableDevtool.DetectorType enumerates all monitoring modes
enum DetectorType {
Unknown = -1,
RegToString = 0, // Check according to regular
DefineId, // detect based on dom id
Size, // Detect based on window size
DateToString, // check against Date.toString
FuncToString, // check according to Function.toString
Debugger, // According to breakpoint detection, it is only valid in the case of ios chrome real machine
Performance, // Performance detection based on log big data
DebugLib, // Detect third-party debugging tools
};
The callback parameter of the ondevtoolopen event is the triggered monitoring mode
You can execute business logic in OndevtoolOpen, such as data reporting, user behavior analysis, etc
DisableDevtool({
ondevtoolopen(type, next){
alert('Devtool opened with type:' + type);
next();
}
});
Used to get whether DisableDevtool is running (the pending or ignore state is also considered running because it can be turned on dynamically)
DisableDevtool.isRunning;
Used to get or set whether DisableDevtool is suspended (suspended state, all disabled will be temporarily disabled)
DisableDevtool.isSuspend = true;
DisableDevtool.isSuspend = false;
ignore is used to customize certain ignored scenarios
The incoming array is supported by strings and regular expressions that indicate whether the matching link contains the incoming content, using the following
DisableDevtool({
ignore: [
'/user/login', // Disabled is temporarily ignored when the link contains this content
/\/user\/[0-9]{6}/, // When a link matches that regular, disabling is temporarily ignored
]
});
The passing function represents a custom judgment condition and returns a bool type, as follows
DisableDevtool({
ignore: () => {
return userType === 'admin'; // Disable is ignored when you are an administrator
}
});
Get DisableDevtool version
DisableDevtool.version;