feat: 0.2.2
This commit is contained in:
parent
d85fc710db
commit
21d17b2d04
@ -36,6 +36,9 @@
|
|||||||
// next();
|
// next();
|
||||||
// console.log(next);
|
// console.log(next);
|
||||||
},
|
},
|
||||||
|
ondevtoolclose: function(){
|
||||||
|
text.innerHTML = 'devtool closed!'
|
||||||
|
},
|
||||||
clearIntervalWhenDevOpenTrigger: false,
|
clearIntervalWhenDevOpenTrigger: false,
|
||||||
interval: 1000,
|
interval: 1000,
|
||||||
// tkName: 'ddtk',
|
// tkName: 'ddtk',
|
||||||
|
9
helper/todo.md
Normal file
9
helper/todo.md
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<!--
|
||||||
|
* @Author: tackchen
|
||||||
|
* @Date: 2022-01-06 00:09:44
|
||||||
|
* @LastEditors: tackchen
|
||||||
|
* @LastEditTime: 2022-01-06 00:11:25
|
||||||
|
* @FilePath: /disable-devtool/helper/todo.md
|
||||||
|
* @Description: Coding something
|
||||||
|
-->
|
||||||
|
1. 问题:ios真机chrome 浏览器 data-to-string 和 func-to-string两个detector与开发者工具表现一致
|
@ -80,7 +80,7 @@
|
|||||||
3. Refactor the code
|
3. Refactor the code
|
||||||
4. Fix the problem caused by the method on the console cannot be cached by ie
|
4. Fix the problem caused by the method on the console cannot be cached by ie
|
||||||
|
|
||||||
## 0.2.1
|
## 0.2.1 - 0.2.2
|
||||||
1. Add ondevtoolclose configuration
|
1. Add ondevtoolclose configuration
|
||||||
2. Add isDevToolOpened api
|
2. Add isDevToolOpened api
|
||||||
3. Fix the accidental injury problem of ios mobile chrome
|
3. Fix the accidental injury problem of ios mobile chrome
|
||||||
|
@ -81,7 +81,7 @@
|
|||||||
3. 重构代码
|
3. 重构代码
|
||||||
4. 修复ie不能缓存console上的方法导致的问题
|
4. 修复ie不能缓存console上的方法导致的问题
|
||||||
|
|
||||||
## 0.2.1
|
## 0.2.1 - 0.2.2
|
||||||
1. 增加 ondevtoolclose 配置
|
1. 增加 ondevtoolclose 配置
|
||||||
2. 增加 isDevToolOpened api
|
2. 增加 isDevToolOpened api
|
||||||
3. 修复 ios mobile chrome 的误伤问题
|
3. 修复 ios mobile chrome 的误伤问题
|
||||||
|
@ -183,7 +183,7 @@ declare type DETECTOR_TYPE = -1 | 0 | 1 | 2 | 3 | 4 | 5;</code></p>
|
|||||||
<script
|
<script
|
||||||
disable-devtool-auto
|
disable-devtool-auto
|
||||||
md5='1aabac6d068eef6a7bad3fdf50a05cc8'
|
md5='1aabac6d068eef6a7bad3fdf50a05cc8'
|
||||||
src='https://cdn.jsdelivr.net/npm/disable-devtool@0.2.1/disable-devtool.min.js#use'
|
src='https://cdn.jsdelivr.net/npm/disable-devtool@0.2.2/disable-devtool.min.js#use'
|
||||||
></script>
|
></script>
|
||||||
<!-- <script disable-devtool-auto md5='1aabac6d068eef6a7bad3fdf50a05cc8' src='./npm/disable-devtool.min.js'></script> -->
|
<!-- <script disable-devtool-auto md5='1aabac6d068eef6a7bad3fdf50a05cc8' src='./npm/disable-devtool.min.js'></script> -->
|
||||||
<script>
|
<script>
|
||||||
|
2
npm/disable-devtool.min.js
vendored
2
npm/disable-devtool.min.js
vendored
File diff suppressed because one or more lines are too long
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "disable-devtool",
|
"name": "disable-devtool",
|
||||||
"version": "0.2.1",
|
"version": "0.2.2",
|
||||||
"description": "Disable web developer tools from the f12 button, right-click and browser ",
|
"description": "Disable web developer tools from the f12 button, right-click and browser ",
|
||||||
"main": "disable-devtool.min.js",
|
"main": "disable-devtool.min.js",
|
||||||
"unpkg": "disable-devtool.min.js",
|
"unpkg": "disable-devtool.min.js",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "disable-devtool",
|
"name": "disable-devtool",
|
||||||
"version": "0.2.1",
|
"version": "0.2.2",
|
||||||
"description": "Disable web developer tools from the f12 button, right-click and browser ",
|
"description": "Disable web developer tools from the f12 button, right-click and browser ",
|
||||||
"main": "disable-devtool.min.js",
|
"main": "disable-devtool.min.js",
|
||||||
"unpkg": "disable-devtool.min.js",
|
"unpkg": "disable-devtool.min.js",
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* @Author: tackchen
|
* @Author: tackchen
|
||||||
* @Date: 2021-11-15 22:26:57
|
* @Date: 2021-11-15 22:26:57
|
||||||
* @LastEditors: tackchen
|
* @LastEditors: tackchen
|
||||||
* @LastEditTime: 2022-01-05 22:40:41
|
* @LastEditTime: 2022-01-06 00:08:02
|
||||||
* @FilePath: /disable-devtool/src/detector/date-to-string.js
|
* @FilePath: /disable-devtool/src/detector/date-to-string.js
|
||||||
* @Description: Coding something
|
* @Description: Coding something
|
||||||
*/
|
*/
|
||||||
@ -11,8 +11,8 @@ import {registInterval} from '../utils/interval';
|
|||||||
import {DETECTOR_TYPE, triggerOnDevOpen} from './detector';
|
import {DETECTOR_TYPE, triggerOnDevOpen} from './detector';
|
||||||
import {clearLog, log} from '../utils/log';
|
import {clearLog, log} from '../utils/log';
|
||||||
|
|
||||||
export default function detector (isTrueIOSChrome) {
|
export default function detector (isIOSChrome) {
|
||||||
if (isTrueIOSChrome) return;
|
if (isIOSChrome) return;
|
||||||
const type = DETECTOR_TYPE.DATE_TO_STRING;
|
const type = DETECTOR_TYPE.DATE_TO_STRING;
|
||||||
let count = 0;
|
let count = 0;
|
||||||
const date = new Date();
|
const date = new Date();
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* @Author: tackchen
|
* @Author: tackchen
|
||||||
* @Date: 2021-11-15 22:26:57
|
* @Date: 2021-11-15 22:26:57
|
||||||
* @LastEditors: tackchen
|
* @LastEditors: tackchen
|
||||||
* @LastEditTime: 2022-01-05 22:38:55
|
* @LastEditTime: 2022-01-06 00:08:11
|
||||||
* @FilePath: /disable-devtool/src/detector/debugger.js
|
* @FilePath: /disable-devtool/src/detector/debugger.js
|
||||||
* @Description: Coding something
|
* @Description: Coding something
|
||||||
*/
|
*/
|
||||||
@ -10,8 +10,8 @@
|
|||||||
import {registInterval} from '../utils/interval';
|
import {registInterval} from '../utils/interval';
|
||||||
import {DETECTOR_TYPE, triggerOnDevOpen} from './detector';
|
import {DETECTOR_TYPE, triggerOnDevOpen} from './detector';
|
||||||
|
|
||||||
export default function detector (isTrueIOSChrome) {
|
export default function detector (isIOSChrome) {
|
||||||
if (isTrueIOSChrome) {
|
if (isIOSChrome) {
|
||||||
const type = DETECTOR_TYPE.DEBUGGER;
|
const type = DETECTOR_TYPE.DEBUGGER;
|
||||||
// 仅在 ios chrome 下生效
|
// 仅在 ios chrome 下生效
|
||||||
registInterval(type, () => {
|
registInterval(type, () => {
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* @Author: theajack
|
* @Author: theajack
|
||||||
* @Date: 2021-07-24 23:16:34
|
* @Date: 2021-07-24 23:16:34
|
||||||
* @LastEditor: theajack
|
* @LastEditor: theajack
|
||||||
* @LastEditTime: 2022-01-05 23:39:06
|
* @LastEditTime: 2022-01-06 00:09:02
|
||||||
* @Description: Coding something
|
* @Description: Coding something
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -16,7 +16,7 @@ import DebuggerDetector from './debugger';
|
|||||||
// import LogTimeDetector from './log-time'; // 不准确 容易误伤 故弃用
|
// import LogTimeDetector from './log-time'; // 不准确 容易误伤 故弃用
|
||||||
import {clearDDInterval, clearDDTimeout} from '../utils/interval';
|
import {clearDDInterval, clearDDTimeout} from '../utils/interval';
|
||||||
import {closeWindow} from '../utils/close-window';
|
import {closeWindow} from '../utils/close-window';
|
||||||
import {isIOSChrome, isLogRegExpCount3} from '../utils/util';
|
import {isIOSChrome} from '../utils/util';
|
||||||
import {isDevToolOpened, isLastStateOpened, markDevToolOpenState} from '../utils/open-state';
|
import {isDevToolOpened, isLastStateOpened, markDevToolOpenState} from '../utils/open-state';
|
||||||
|
|
||||||
export const DETECTOR_TYPE = {
|
export const DETECTOR_TYPE = {
|
||||||
@ -41,31 +41,19 @@ const Detectors = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export function initDetectors () {
|
export function initDetectors () {
|
||||||
// ! 判断是否是 ios chrome 真机, true时 禁用 date 和 func detector,因为会误伤。启用debugger detector兜底
|
// ! 判断是否是 ios chrome true时 禁用 date 和 func detector,因为会误伤。启用debugger detector兜底
|
||||||
// 不使用 async/await 是为了减少打包体积
|
|
||||||
|
|
||||||
const initFunc = (isTrueIOSChrome) => {
|
|
||||||
const typeArray = config.detectors === 'all' ?
|
const typeArray = config.detectors === 'all' ?
|
||||||
Object.keys(Detectors) : config.detectors;
|
Object.keys(Detectors) : config.detectors;
|
||||||
|
|
||||||
if (isTrueIOSChrome) {
|
if (isIOSChrome) {
|
||||||
typeArray.push(DETECTOR_TYPE.DEBUGGER); // 会debuger显示devtool, 仅在ios chrome 真机生效
|
typeArray.push(DETECTOR_TYPE.DEBUGGER); // 会debuger显示devtool, 仅在ios chrome 真机生效
|
||||||
}
|
}
|
||||||
|
|
||||||
typeArray.forEach(type => {
|
typeArray.forEach(type => {
|
||||||
if (Detectors[type]) {
|
if (Detectors[type]) {
|
||||||
Detectors[type](isTrueIOSChrome);
|
Detectors[type](isIOSChrome);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
|
||||||
|
|
||||||
if (!isIOSChrome) {
|
|
||||||
initFunc(false);
|
|
||||||
} else {
|
|
||||||
isLogRegExpCount3().then(bool => {
|
|
||||||
initFunc(bool);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function triggerOnDevOpen (type = DETECTOR_TYPE.UNKONW) {
|
export function triggerOnDevOpen (type = DETECTOR_TYPE.UNKONW) {
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* @Author: tackchen
|
* @Author: tackchen
|
||||||
* @Date: 2021-11-15 22:26:57
|
* @Date: 2021-11-15 22:26:57
|
||||||
* @LastEditors: tackchen
|
* @LastEditors: tackchen
|
||||||
* @LastEditTime: 2022-01-05 22:39:48
|
* @LastEditTime: 2022-01-06 00:07:54
|
||||||
* @FilePath: /disable-devtool/src/detector/func-to-string.js
|
* @FilePath: /disable-devtool/src/detector/func-to-string.js
|
||||||
* @Description: Coding something
|
* @Description: Coding something
|
||||||
*/
|
*/
|
||||||
@ -13,8 +13,8 @@ import {registInterval} from '../utils/interval';
|
|||||||
import {DETECTOR_TYPE, triggerOnDevOpen} from './detector';
|
import {DETECTOR_TYPE, triggerOnDevOpen} from './detector';
|
||||||
import {log, clearLog} from '../utils/log';
|
import {log, clearLog} from '../utils/log';
|
||||||
|
|
||||||
export default function detector (isTrueIOSChrome) {
|
export default function detector (isIOSChrome) {
|
||||||
if (isTrueIOSChrome) return;
|
if (isIOSChrome) return;
|
||||||
const type = DETECTOR_TYPE.FUNC_TO_STRING;
|
const type = DETECTOR_TYPE.FUNC_TO_STRING;
|
||||||
let count = 0;
|
let count = 0;
|
||||||
const func = () => {};
|
const func = () => {};
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
import {log} from './log';
|
|
||||||
|
|
||||||
export function isPC () {
|
export function isPC () {
|
||||||
return !/(iphone|ipad|ipod|ios|android)/i.test(navigator.userAgent.toLowerCase());
|
return !/(iphone|ipad|ipod|ios|android)/i.test(navigator.userAgent.toLowerCase());
|
||||||
}
|
}
|
||||||
@ -114,19 +112,3 @@ export const isOldEdge = hasUaName('edge') && !hasUaName('chrome');
|
|||||||
export const isIE = isOldEdge || hasUaName('trident') || hasUaName('msie');
|
export const isIE = isOldEdge || hasUaName('trident') || hasUaName('msie');
|
||||||
|
|
||||||
export const isIOSChrome = hasUaName('crios');
|
export const isIOSChrome = hasUaName('crios');
|
||||||
|
|
||||||
// ios chrome log regExp count=3 , 以此区别真机和开发者工具模拟的
|
|
||||||
export function isLogRegExpCount3 () {
|
|
||||||
return new Promise((resolve) => {
|
|
||||||
let count = 0;
|
|
||||||
const target = new RegExp();
|
|
||||||
target.toString = () => {
|
|
||||||
count ++;
|
|
||||||
return '';
|
|
||||||
};
|
|
||||||
log(target);
|
|
||||||
setTimeout(() => {
|
|
||||||
resolve(count === 3);
|
|
||||||
}, 100);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
@ -1 +1 @@
|
|||||||
export default '0.2.1';
|
export default '0.2.2';
|
Loading…
x
Reference in New Issue
Block a user