feat: 0.1.7

This commit is contained in:
tackchen 2021-11-15 23:58:47 +08:00
parent 2d986cf12a
commit f8d01801b8
23 changed files with 280 additions and 70 deletions

View File

@ -110,10 +110,11 @@ declare interface optionStatic {
interval?: number; // 定时器的时间间隔 默认200ms
disableMenu?: boolean; // 是否禁用右键菜单 默认为true
stopIntervalTime?: number; // 在移动端时取消监视的等待时长
clearIntervalWhenDevOpenTrigger?: boolean; // 是否在触发之后停止监控
clearIntervalWhenDevOpenTrigger?: boolean; // 是否在触发之后停止监控 默认为false
detactors?: Array<DETECTOR_TYPE>; // 启用的检测器 检测器详情见 3.5 默认为全部,建议使用全部
}
declare type DETECTOR_TYPE = -1 | 0 | 1 | 2 | 3;
declare type DETECTOR_TYPE = -1 | 0 | 1 | 2 | 3 | 4; // 检测器详情见 3.5
```
### 3.2 md5 与 tk 绕过禁用
@ -141,6 +142,7 @@ disableDevtool.md5('xxx');
tk-name='xxx'
interval='xxx'
disable-menu='xxx'
detectors='xxx'
></script>
```
@ -149,6 +151,7 @@ disableDevtool.md5('xxx');
1. 如希望自动禁用,属性配置时必须要带上 `disable-devtool-auto` 属性
2. 属性配置都是可选的字段与3.1中一致,区别是将驼峰形式改成横线分割
3. 该script标签建议放在body最底部
4. detectors 需要使用空格分割,如 detectors='1 2 3'
### 3.4 script不使用属性配置
@ -163,14 +166,16 @@ disableDevtool.md5('xxx');
### 3.5 监测模式
Disable-Devtool 有种监测模式, DisableDevtool.DETECTOR_TYPE 为所有的监测模式
Disable-Devtool 有种监测模式, DisableDevtool.DETECTOR_TYPE 为所有的监测模式枚举
```js
const DETECTOR_TYPE = {
UNKONW: -1,
TO_STRING: 0,
DEFINE_ID: 1,
SIZE: 2,
REG_TO_STRING: 0, // 根据正则检测
DEFINE_ID: 1, // 根据dom id检测
SIZE: 2, // 根据窗口尺寸检测
DATE_TO_STRING: 3, // 根据Date.toString 检测
FUNC_TO_STRING: 4, // 根据Function.toString 检测
}
```

View File

@ -35,7 +35,7 @@
<a href="https://github.com/theajack/disable-devtool/blob/master/test/test-report.txt"><img src="https://img.shields.io/badge/test-passed-44BB44" alt="test"></a>
</p>
**[中文](https://github.com/theajack/disable-devtool/blob/master/README.cn.md) | [online trial/document](https://theajack.gitee.io/disable-devtool) | [Version Log](https://github.com/theajack/disable-devtool/blob/master/helper/version.md) | [Gitee](https://gitee.com/theajack/disable-devtool)**
**[中文](https://github.com/theajack/disable-devtool/blob/master/README.cn.md) | [online trial/document](https://theajack.gitee.io/disable-devtool) | [Version Log](https://github.com/theajack/disable-devtool/blob/master/helper/version.en.md) | [Gitee](https://gitee.com/theajack/disable-devtool)**
## 1. Quick use
@ -108,11 +108,11 @@ declare interface optionStatic {
ondevtoolopen?(type: DetectorType): void; // Callback for opening the developer panel, the url parameter is invalid when it is enabled, and the type is the monitoring mode, see 3.5 for details
interval?: number; // Timer interval is 200ms by default
disableMenu?: boolean; // Whether to disable the right-click menu The default is true
stopIntervalTime?: number; // Waiting time to cancel monitoring on mobile
clearIntervalWhenDevOpenTrigger?: boolean; // Whether to stop monitoring after triggering
clearIntervalWhenDevOpenTrigger?: boolean; // Whether to stop monitoring after triggering The default is false
detactors?: Array<DETECTOR_TYPE>; // Enabled detectors For details of detectors, see 3.5. The default is all, it is recommended to use all
}
declare type DETECTOR_TYPE = -1 | 0 | 1 | 2 | 3;
declare type DETECTOR_TYPE = -1 | 0 | 1 | 2 | 3 | 4; // For details of the detector, see 3.5
```
### 3.2 md5 and tk bypass disable
@ -140,6 +140,7 @@ disableDevtool.md5('xxx');
tk-name='xxx'
interval='xxx'
disable-menu='xxx'
detectors='xxx'
></script>
```
@ -148,6 +149,7 @@ Note:
1. If you want to automatically disable,you must bring the `disable-devtool-auto` attribute when configuring attributes
2. Attribute configuration is optional, the fields are the same as in 3.1, the difference is that the hump form is changed to horizontal line division
3. The script tag is recommended to be placed at the bottom of the body
4. detectors Need to use spaces to separate, such as detectors='1 2 3'
### 3.4 script does not use attribute configuration
@ -162,14 +164,16 @@ Note:
### 3.5 Monitoring Mode
Disable-Devtool has four monitoring modes, DisableDevtool.DETECTOR_TYPE is all monitoring modes
Disable-Devtool has five monitoring modes, DisableDevtool.DETECTOR_TYPE is an enumeration of all monitoring modes
```js
const DETECTOR_TYPE = {
UNKONW: -1,
TO_STRING: 0,
DEFINE_ID: 1,
SIZE: 2,
UNKONW: -1,
REG_TO_STRING: 0, // According to regular detection
DEFINE_ID: 1, // Detect according to dom id
SIZE: 2, // Detect according to window size
DATE_TO_STRING: 3, // Check according to Date.toString
FUNC_TO_STRING: 4, // Detect according to Function.toString
}
```

62
helper/version.en.md Normal file
View File

@ -0,0 +1,62 @@
# Version Log:
## 0.0.1
1. Support configurable whether to disable the right-click menu
2. Disable f12 and ctrl+shift+i shortcuts
3. Support recognition to open the developer tools from the browser menu bar and close the current page
4. Developers can bypass the disabling (use tk and md5 encryption for url parameters)
5. Support almost all browsers
6. Highly configurable
7. Minimal use, small size (only 7kb)
8. Support npm reference and script tag reference (attribute configuration)
## 0.0.2
1. Solve the bug of invalid CDN file
## 0.0.3
1. Solve the problem of native methods such as alert that will affect debug timing
2. Resolve the page and the background will affect the debug timing.
3. Compatible with ie, the disableMenu parameter is invalid under ie, because the right-click under ie will block the main process and cannot monitor
4. Add config.stopIntervalTime to indicate the waiting time for canceling monitoring on the mobile terminal
5. Optimize the logic of judging the opening of the developer tool
## 0.0.4
1. Modify webpack packaging configuration
## 0.0.5
1. Optimize onDevToolOpen event trigger logic
## 0.0.6
1. For the label attribute configuration, remove the id='disable-devtool' condition and use the disable-devtool-auto attribute
2. Modify the readme
## 0.1.0
1. Fix the invalid problem under firefox and qq browser
2. Enable disableMenu configuration
3. Remove internal debug logic
4. Add the default redirect 404 page
## 0.1.1
1. Increase the delay of jumping to the default page after history.back
2. Optimize ondeltoolopen logic
## 0.1.2
1. Add the judgment of the document to adapt to the server-side rendering npm call
## 0.1.3
1. Fix the bug that disableMenu parameter is invalid
## 0.1.4
1. Add detector, add multiple monitoring modes
2. Use logTime mode, compatible with mac and linux
3. Add the clearIntervalWhenDevOpenTrigger parameter
4. ondevtoolopen adds monitoring mode callback parameters
## 0.1.5
1. Remove the log-time monitoring type (because of inaccuracy)
## 0.1.6 - 0.1.7
1. Add DateToString monitoring type
2. Add FuncToString monitoring type
3. Add detectors configuration
4. Fix ios 15 accidental injury problem

View File

@ -53,5 +53,10 @@
4. ondevtoolopen 增加 监测模式 回调参数
## 0.1.5
1. 去掉log-time监测类型因为不准确
## 0.1.6 - 0.1.7
1. 增加 DateToString 监测类型
2. 增加 FuncToString 监测类型
3. 增加 detectors 配置
4. 修复ios 15误伤问题

View File

@ -126,6 +126,7 @@ disableDevtool(options);</code></p>
disableMenu?: boolean; // Whether to disable the right-click menu The default is true
stopIntervalTime?: number; // Waiting time to cancel monitoring on mobile
clearIntervalWhenDevOpenTrigger?: boolean; // Whether to stop monitoring after triggering
detactors?: Array; // Enabled detectors For details of detectors, see 3.5. The default is all, it is recommended to use all
}
declare type DETECTOR_TYPE = -1 | 0 | 1 | 2 | 3;</code></p>
@ -160,7 +161,8 @@ declare type DETECTOR_TYPE = -1 | 0 | 1 | 2 | 3;</code></p>
url=&#39;xxx&#39;
tk-name=&#39;xxx&#39;
interval=&#39;xxx&#39;
disable-menu=&#39;xxx&#39;>
disable-menu=&#39;xxx&#39;
detectors=&#39;xxx&#39;>
&lt;/script&gt;</code></p>
</blockquote>
@ -168,7 +170,8 @@ declare type DETECTOR_TYPE = -1 | 0 | 1 | 2 | 3;</code></p>
1. You must bring the <strong>disable-devtool-auto</strong> attribute when configuring attributes<br>
2.Attribute configuration is optional, the fields are the same as in 3.1, the difference is that the hump form is
changed to horizontal line division <br>
3. The script tag is recommended to be placed at the bottom of the body</p>
3. The script tag is recommended to be placed at the bottom of the body <br>
4. detectors Need to use spaces to separate, such as detectors='1 2 3'</p>
<h3>3.3 script does not use attribute configuration</h3>
@ -181,7 +184,7 @@ declare type DETECTOR_TYPE = -1 | 0 | 1 | 2 | 3;</code></p>
<script
disable-devtool-auto
md5='1aabac6d068eef6a7bad3fdf50a05cc8'
src='https://cdn.jsdelivr.net/npm/disable-devtool@0.1.5/disable-devtool.min.js#use'
src='https://cdn.jsdelivr.net/npm/disable-devtool@0.1.7/disable-devtool.min.js#use'
></script>
<!-- <script disable-devtool-auto md5='1aabac6d068eef6a7bad3fdf50a05cc8' src='./npm/disable-devtool.min.js'></script> -->
<script>

View File

@ -110,10 +110,11 @@ declare interface optionStatic {
interval?: number; // 定时器的时间间隔 默认200ms
disableMenu?: boolean; // 是否禁用右键菜单 默认为true
stopIntervalTime?: number; // 在移动端时取消监视的等待时长
clearIntervalWhenDevOpenTrigger?: boolean; // 是否在触发之后停止监控
clearIntervalWhenDevOpenTrigger?: boolean; // 是否在触发之后停止监控 默认为false
detactors?: Array<DETECTOR_TYPE>; // 启用的检测器 检测器详情见 3.5 默认为全部,建议使用全部
}
declare type DETECTOR_TYPE = -1 | 0 | 1 | 2 | 3;
declare type DETECTOR_TYPE = -1 | 0 | 1 | 2 | 3 | 4; // 检测器详情见 3.5
```
### 3.2 md5 与 tk 绕过禁用
@ -141,6 +142,7 @@ disableDevtool.md5('xxx');
tk-name='xxx'
interval='xxx'
disable-menu='xxx'
detectors='xxx'
></script>
```
@ -149,6 +151,7 @@ disableDevtool.md5('xxx');
1. 如希望自动禁用,属性配置时必须要带上 `disable-devtool-auto` 属性
2. 属性配置都是可选的字段与3.1中一致,区别是将驼峰形式改成横线分割
3. 该script标签建议放在body最底部
4. detectors 需要使用空格分割,如 detectors='1 2 3'
### 3.4 script不使用属性配置
@ -163,14 +166,16 @@ disableDevtool.md5('xxx');
### 3.5 监测模式
Disable-Devtool 有种监测模式, DisableDevtool.DETECTOR_TYPE 为所有的监测模式
Disable-Devtool 有种监测模式, DisableDevtool.DETECTOR_TYPE 为所有的监测模式枚举
```js
const DETECTOR_TYPE = {
UNKONW: -1,
TO_STRING: 0,
DEFINE_ID: 1,
SIZE: 2,
REG_TO_STRING: 0, // 根据正则检测
DEFINE_ID: 1, // 根据dom id检测
SIZE: 2, // 根据窗口尺寸检测
DATE_TO_STRING: 3, // 根据Date.toString 检测
FUNC_TO_STRING: 4, // 根据Function.toString 检测
}
```

View File

@ -35,7 +35,7 @@
<a href="https://github.com/theajack/disable-devtool/blob/master/test/test-report.txt"><img src="https://img.shields.io/badge/test-passed-44BB44" alt="test"></a>
</p>
**[中文](https://github.com/theajack/disable-devtool/blob/master/README.cn.md) | [online trial/document](https://theajack.gitee.io/disable-devtool) | [Version Log](https://github.com/theajack/disable-devtool/blob/master/helper/version.md) | [Gitee](https://gitee.com/theajack/disable-devtool)**
**[中文](https://github.com/theajack/disable-devtool/blob/master/README.cn.md) | [online trial/document](https://theajack.gitee.io/disable-devtool) | [Version Log](https://github.com/theajack/disable-devtool/blob/master/helper/version.en.md) | [Gitee](https://gitee.com/theajack/disable-devtool)**
## 1. Quick use
@ -108,11 +108,11 @@ declare interface optionStatic {
ondevtoolopen?(type: DetectorType): void; // Callback for opening the developer panel, the url parameter is invalid when it is enabled, and the type is the monitoring mode, see 3.5 for details
interval?: number; // Timer interval is 200ms by default
disableMenu?: boolean; // Whether to disable the right-click menu The default is true
stopIntervalTime?: number; // Waiting time to cancel monitoring on mobile
clearIntervalWhenDevOpenTrigger?: boolean; // Whether to stop monitoring after triggering
clearIntervalWhenDevOpenTrigger?: boolean; // Whether to stop monitoring after triggering The default is false
detactors?: Array<DETECTOR_TYPE>; // Enabled detectors For details of detectors, see 3.5. The default is all, it is recommended to use all
}
declare type DETECTOR_TYPE = -1 | 0 | 1 | 2 | 3;
declare type DETECTOR_TYPE = -1 | 0 | 1 | 2 | 3 | 4; // For details of the detector, see 3.5
```
### 3.2 md5 and tk bypass disable
@ -140,6 +140,7 @@ disableDevtool.md5('xxx');
tk-name='xxx'
interval='xxx'
disable-menu='xxx'
detectors='xxx'
></script>
```
@ -148,6 +149,7 @@ Note:
1. If you want to automatically disable,you must bring the `disable-devtool-auto` attribute when configuring attributes
2. Attribute configuration is optional, the fields are the same as in 3.1, the difference is that the hump form is changed to horizontal line division
3. The script tag is recommended to be placed at the bottom of the body
4. detectors Need to use spaces to separate, such as detectors='1 2 3'
### 3.4 script does not use attribute configuration
@ -162,14 +164,16 @@ Note:
### 3.5 Monitoring Mode
Disable-Devtool has four monitoring modes, DisableDevtool.DETECTOR_TYPE is all monitoring modes
Disable-Devtool has five monitoring modes, DisableDevtool.DETECTOR_TYPE is an enumeration of all monitoring modes
```js
const DETECTOR_TYPE = {
UNKONW: -1,
TO_STRING: 0,
DEFINE_ID: 1,
SIZE: 2,
UNKONW: -1,
REG_TO_STRING: 0, // According to regular detection
DEFINE_ID: 1, // Detect according to dom id
SIZE: 2, // Detect according to window size
DATE_TO_STRING: 3, // Check according to Date.toString
FUNC_TO_STRING: 4, // Detect according to Function.toString
}
```

File diff suppressed because one or more lines are too long

10
npm/index.d.ts vendored
View File

@ -1,5 +1,5 @@
declare type DETECTOR_TYPE = -1 | 0 | 1 | 2;
declare type DETECTOR_TYPE = -1 | 0 | 1 | 2 | 3 | 4;
declare interface optionStatic {
md5?: string; // 绕过禁用的md5值详情见3.2,默认不启用绕过禁用
url?: string; // 关闭页面失败时的跳转页面默认值为localhost
@ -9,16 +9,20 @@ declare interface optionStatic {
disableMenu?: boolean; // 是否禁用右键菜单 默认为true
stopIntervalTime?: number; // 在移动端时取消监视的等待时长
clearIntervalWhenDevOpenTrigger?: boolean; // 是否在触发之后停止监控
detectors: Array<DETECTOR_TYPE>; // 启用的监测器 默认为全部
}
declare interface DDTStatic {
(option?: optionStatic): void;
md5(text?: string): string;
DETECTOR_TYPE: {
UNKONW: -1;
TO_STRING: 0;
REG_TO_STRING: 0;
DEFINE_ID: 1;
SIZE: 2;
// LOG_TIME: 3;
DATE_TO_STRING: 3;
FUNC_TO_STRING: 4;
// DEBUGGER: 5;
// LOG_TIME: 6;
}
version: string;
}

View File

@ -1,6 +1,6 @@
{
"name": "disable-devtool",
"version": "0.1.5",
"version": "0.1.7",
"description": "Disable web developer tools from the f12 button, right-click and browser ",
"main": "disable-devtool.min.js",
"unpkg": "disable-devtool.min.js",

View File

@ -1,6 +1,6 @@
{
"name": "disable-devtool",
"version": "0.1.5",
"version": "0.1.7",
"description": "Disable web developer tools from the f12 button, right-click and browser ",
"main": "disable-devtool.min.js",
"unpkg": "disable-devtool.min.js",

View File

@ -4,16 +4,17 @@ import disableDevtool from '../src';
// debugger;
disableDevtool({
md5: 'd4de605ccb923b7e876b3218a1474653',
md5: '0b9e05caf5000360ec1c263335bd83fe', // ddtk
// url: 'https://www.qq.com',
// ondevtoolopen: () => {
// window.location.href = 'https://www.qq.com';
// },
interval: 1000,
tkName: 'xx',
// tkName: 'ddtk',
// disableMenu: false
// url: 'https://www.baidu.com'
// detectors: [disableDevtool.DETECTOR_TYPE.DATE_TO_STRING],
});
console.log(disableDevtool.version);
console.log(disableDevtool.md5('theajack'));
// console.log(disableDevtool.version);
// console.log(disableDevtool.md5('xx'));

View File

@ -9,11 +9,17 @@ export const config = {
disableMenu: true, // 该参数ie下无效ie 右键菜单会阻塞线程影响debug延迟计算 禁用右键菜单
stopIntervalTime: 5000, // 在移动端时取消监视的等待时长
clearIntervalWhenDevOpenTrigger: false, // 是否在触发之后停止监控
detectors: 'all',
};
const MultiTypeKeys = ['detectors'];
export function mergeConfig (opts = {}) {
for (const k in config) {
if (typeof opts[k] !== 'undefined' && typeof config[k] === typeof opts[k]) {
if (
typeof opts[k] !== 'undefined' &&
(typeof config[k] === typeof opts[k] || MultiTypeKeys.includes(k))
) {
config[k] = opts[k];
}
}

View File

@ -0,0 +1,31 @@
/*
* @Author: tackchen
* @Date: 2021-11-15 22:26:57
* @LastEditors: tackchen
* @LastEditTime: 2021-11-15 23:48:53
* @FilePath: /disable-devtool/src/detector/date-to-string.js
* @Description: Coding something
*/
import {registInterval} from '../interval';
import {DETECTOR_TYPE, triggerOnDevOpen} from './detector';
export default function detector () {
let count = 0;
const date = new Date();
date.toString = () => {
count ++;
return '';
};
const checkIsOpen = () => {
count = 0;
console.log(date);
console.clear();
if (count >= 2) {
triggerOnDevOpen(DETECTOR_TYPE.DATE_TO_STRING);
}
};
registInterval(checkIsOpen);
}

21
src/detector/debugger.js Normal file
View File

@ -0,0 +1,21 @@
/*
* @Author: tackchen
* @Date: 2021-11-15 22:26:57
* @LastEditors: tackchen
* @LastEditTime: 2021-11-15 23:49:00
* @FilePath: /disable-devtool/src/detector/debugger.js
* @Description: Coding something
*/
import {registInterval} from '../interval';
import {DETECTOR_TYPE, triggerOnDevOpen} from './detector';
export default function detector () {
registInterval(() => {
const date = Date.now();
(() => {debugger;})();
if (Date.now() - date > 100) {
triggerOnDevOpen(DETECTOR_TYPE.DEBUGGER);
}
});
}

View File

@ -2,25 +2,40 @@
* @Author: theajack
* @Date: 2021-07-24 23:16:34
* @LastEditor: theajack
* @LastEditTime: 2021-07-27 23:36:44
* @LastEditTime: 2021-11-15 23:55:08
* @Description: Coding something
*/
import {config} from '../config';
import ToStringDetector from './to-string';
import RegToStringDetector from './reg-to-string';
import DefineIdDetector from './define-id';
import SizeDetector from './size';
// import LogTimeDetector from './log-time';
import DateToStringDetector from './date-to-string';
import FuncToStringDetector from './func-to-string';
// import DebuggerDetector from './debugger'; // 会debuger显示devtool
// import LogTimeDetector from './log-time'; // 不准确 容易误伤
import {clearDDInterval, clearDDTimeout} from '../interval';
const detectorList = [];
export const DETECTOR_TYPE = {
UNKONW: -1,
TO_STRING: 0,
REG_TO_STRING: 0,
DEFINE_ID: 1,
SIZE: 2,
// LOG_TIME: 3,
DATE_TO_STRING: 3,
FUNC_TO_STRING: 4,
// DEBUGGER: 5,
// LOG_TIME: 6,
};
const Detectors = {
[DETECTOR_TYPE.REG_TO_STRING]: RegToStringDetector,
[DETECTOR_TYPE.DEFINE_ID]: DefineIdDetector,
[DETECTOR_TYPE.SIZE]: SizeDetector,
[DETECTOR_TYPE.DATE_TO_STRING]: DateToStringDetector,
[DETECTOR_TYPE.FUNC_TO_STRING]: FuncToStringDetector,
// [DETECTOR_TYPE.DEBUGGER]: DebuggerDetector,
};
export function registDetector (detector) {
@ -28,14 +43,20 @@ export function registDetector (detector) {
}
export function initDetectors () {
ToStringDetector();
DefineIdDetector();
SizeDetector();
// LogTimeDetector();
const typeArray = config.detectors === 'all' ?
Object.keys(Detectors) : config.detectors;
typeArray.forEach(type => {
if (Detectors[type]) {
Detectors[type]();
}
});
}
export function triggerOnDevOpen (type = DETECTOR_TYPE.UNKONW) {
console.warn(`You ar not allow to use DEVTOOL! 【type = ${type}`);
document.body.innerHTML = `You ar not allow to use DEVTOOL! 【type = ${type}`;
// alert(`You ar not allow to use DEVTOOL! 【type = ${type}】`);
if (config.clearIntervalWhenDevOpenTrigger) {
clearDDInterval();
}

View File

@ -0,0 +1,31 @@
/*
* @Author: tackchen
* @Date: 2021-11-15 22:26:57
* @LastEditors: tackchen
* @LastEditTime: 2021-11-15 23:49:07
* @FilePath: /disable-devtool/src/detector/func-to-string.js
* @Description: Coding something
*/
import {registInterval} from '../interval';
import {DETECTOR_TYPE, triggerOnDevOpen} from './detector';
export default function detector () {
let count = 0;
const func = () => {};
func.toString = () => {
count ++;
return '';
};
const checkIsOpen = () => {
count = 0;
console.log(func);
console.clear();
if (count >= 2) {
triggerOnDevOpen(DETECTOR_TYPE.FUNC_TO_STRING);
}
};
registInterval(checkIsOpen);
}

View File

@ -2,7 +2,7 @@
* @Author: theajack
* @Date: 2021-07-24 23:15:01
* @LastEditor: theajack
* @LastEditTime: 2021-07-25 16:54:13
* @LastEditTime: 2021-11-15 22:26:29
* @Description: Coding something
*/
@ -22,12 +22,12 @@ export default function detector () {
if (isQQ) { // ! qq浏览器在控制台没有打开的时候也会触发 打开的时候会连续触发两次 使用这个来判断
const time = new Date().getTime();
if (lastTime && time - lastTime < 100) {
triggerOnDevOpen(DETECTOR_TYPE.TO_STRING);
triggerOnDevOpen(DETECTOR_TYPE.REG_TO_STRING);
} else {
lastTime = time;
}
} else if (isFF) {
triggerOnDevOpen(DETECTOR_TYPE.TO_STRING);
triggerOnDevOpen(DETECTOR_TYPE.REG_TO_STRING);
}
return '';
};

View File

@ -2,17 +2,16 @@
* @Author: theajack
* @Date: 2021-07-24 23:15:54
* @LastEditor: theajack
* @LastEditTime: 2021-07-25 17:12:51
* @LastEditTime: 2021-11-15 23:44:27
* @Description: Coding something
* @FilePath: \disable-devtool\src\detector\size.js
* @FilePath: /disable-devtool/src/detector/size.js
*/
import {DETECTOR_TYPE, triggerOnDevOpen} from './detector';
function checkWindowSizeUneven () {
const threshold = 160;
const widthUneven = window.outerWidth - window.innerWidth > threshold;
const heightUneven = window.outerHeight - window.innerHeight > threshold;
const widthUneven = window.outerWidth - window.innerWidth > 20;
const heightUneven = window.outerHeight - window.innerHeight > 250; // 调大一点防止误伤
if (widthUneven || heightUneven) {
triggerOnDevOpen(DETECTOR_TYPE.SIZE);
return false;

10
src/index.d.ts vendored
View File

@ -1,5 +1,5 @@
declare type DETECTOR_TYPE = -1 | 0 | 1 | 2;
declare type DETECTOR_TYPE = -1 | 0 | 1 | 2 | 3 | 4;
declare interface optionStatic {
md5?: string; // 绕过禁用的md5值详情见3.2,默认不启用绕过禁用
url?: string; // 关闭页面失败时的跳转页面默认值为localhost
@ -9,16 +9,20 @@ declare interface optionStatic {
disableMenu?: boolean; // 是否禁用右键菜单 默认为true
stopIntervalTime?: number; // 在移动端时取消监视的等待时长
clearIntervalWhenDevOpenTrigger?: boolean; // 是否在触发之后停止监控
detectors: Array<DETECTOR_TYPE>; // 启用的监测器 默认为全部
}
declare interface DDTStatic {
(option?: optionStatic): void;
md5(text?: string): string;
DETECTOR_TYPE: {
UNKONW: -1;
TO_STRING: 0;
REG_TO_STRING: 0;
DEFINE_ID: 1;
SIZE: 2;
// LOG_TIME: 3;
DATE_TO_STRING: 3;
FUNC_TO_STRING: 4;
// DEBUGGER: 5;
// LOG_TIME: 6;
}
version: string;
}

View File

@ -17,7 +17,7 @@ export function initInterval () {
calls.forEach(fn => {fn(time++);});
console.clear();
}, config.interval);
// 两秒之后判断 如果不是pc去掉定时器interval为了优化移动端的性能
// stopIntervalTime 之后判断 如果不是pc去掉定时器interval为了优化移动端的性能
// 如果控制面板被打开了该定时器timer会被清除
timer = setTimeout(() => {
if (!isPC()) {

View File

@ -37,13 +37,17 @@ function checkScriptUse () {
return;
}
const json = {};
['md5', 'url', 'tk-name', 'interval', 'disable-menu'].forEach(name => {
['md5', 'url', 'tk-name', 'interval', 'disable-menu', 'detectors'].forEach(name => {
let value = dom.getAttribute(name);
if (value !== null) {
if (name === 'interval') {
value = parseInt(value);
} else if (name === 'disable-menu') {
value = value === 'false' ? false : true;
} else if (name === 'detector') {
if (value !== 'all') {
value = value.split(' ');
}
}
json[formatName(name)] = value;
}

View File

@ -1 +1 @@
export default '0.1.5';
export default '0.1.7';