feat: 0.1.12
This commit is contained in:
parent
62eaa7b87a
commit
9a4aec39f1
@ -106,7 +106,7 @@ declare interface optionStatic {
|
|||||||
md5?: string; // 绕过禁用的md5值,详情见3.2,默认不启用绕过禁用
|
md5?: string; // 绕过禁用的md5值,详情见3.2,默认不启用绕过禁用
|
||||||
url?: string; // 关闭页面失败时的跳转页面,默认值为localhost
|
url?: string; // 关闭页面失败时的跳转页面,默认值为localhost
|
||||||
tkName?: string; // 绕过禁用时的url参数名称,默认为 ddtk
|
tkName?: string; // 绕过禁用时的url参数名称,默认为 ddtk
|
||||||
ondevtoolopen?(type: DetectorType): void; // 开发者面板打开的回调,启用时url参数无效,type 为监测模式,详见3.5
|
ondevtoolopen?(type: DetectorType, next: Function): void; // 开发者面板打开的回调,启用时url参数无效,type 为监测模式,详见3.5
|
||||||
interval?: number; // 定时器的时间间隔 默认200ms
|
interval?: number; // 定时器的时间间隔 默认200ms
|
||||||
disableMenu?: boolean; // 是否禁用右键菜单 默认为true
|
disableMenu?: boolean; // 是否禁用右键菜单 默认为true
|
||||||
stopIntervalTime?: number; // 在移动端时取消监视的等待时长
|
stopIntervalTime?: number; // 在移动端时取消监视的等待时长
|
||||||
|
@ -105,7 +105,7 @@ declare interface optionStatic {
|
|||||||
md5?: string; // Bypass the disabled md5 value, see 3.2 for details, the bypass disable is not enabled by default
|
md5?: string; // Bypass the disabled md5 value, see 3.2 for details, the bypass disable is not enabled by default
|
||||||
url?: string; // Jump to the page when closing the page fails, the default value is localhost
|
url?: string; // Jump to the page when closing the page fails, the default value is localhost
|
||||||
tkName?: string; // Bypass the url parameter name when disabled, the default is ddtk
|
tkName?: string; // Bypass the url parameter name when disabled, the default is ddtk
|
||||||
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
|
ondevtoolopen?(type: DetectorType, next: Function): 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
|
interval?: number; // Timer interval is 200ms by default
|
||||||
disableMenu?: boolean; // Whether to disable the right-click menu The default is true
|
disableMenu?: boolean; // Whether to disable the right-click menu The default is true
|
||||||
clearIntervalWhenDevOpenTrigger?: boolean; // Whether to stop monitoring after triggering The default is false
|
clearIntervalWhenDevOpenTrigger?: boolean; // Whether to stop monitoring after triggering The default is false
|
||||||
|
@ -73,4 +73,9 @@
|
|||||||
1. Fix the problem that sizeDetector is accidentally injured in browser zoom mode
|
1. Fix the problem that sizeDetector is accidentally injured in browser zoom mode
|
||||||
|
|
||||||
## 0.1.11
|
## 0.1.11
|
||||||
1. Fix the accidental injury caused by the third-party hack console.log method
|
1. Fix the accidental injury caused by the third-party hack console.log method
|
||||||
|
## 0.1.12
|
||||||
|
1. Add the second parameter of config.ondevtoolopen next
|
||||||
|
2. Added shortcut key operations for prohibiting reviewing elements and saving web pages
|
||||||
|
3. Refactor the code
|
||||||
|
4. Fix the problem caused by the method on the console cannot be cached by ie
|
@ -73,4 +73,10 @@
|
|||||||
1. 修复sizeDetector在浏览器缩放模式下误伤的问题
|
1. 修复sizeDetector在浏览器缩放模式下误伤的问题
|
||||||
|
|
||||||
## 0.1.11
|
## 0.1.11
|
||||||
1. 修复第三方 hack console.log方法 导致的误伤
|
1. 修复第三方 hack console.log方法 导致的误伤
|
||||||
|
|
||||||
|
## 0.1.12
|
||||||
|
1. 增加 config.ondevtoolopen 第二个参数 next
|
||||||
|
2. 增加 禁止审查元素和保存网页的快捷键操作
|
||||||
|
3. 重构代码
|
||||||
|
4. 修复ie不能缓存console上的方法导致的问题
|
@ -182,7 +182,7 @@ declare type DETECTOR_TYPE = -1 | 0 | 1 | 2 | 3;</code></p>
|
|||||||
<script
|
<script
|
||||||
disable-devtool-auto
|
disable-devtool-auto
|
||||||
md5='1aabac6d068eef6a7bad3fdf50a05cc8'
|
md5='1aabac6d068eef6a7bad3fdf50a05cc8'
|
||||||
src='https://cdn.jsdelivr.net/npm/disable-devtool@0.1.11/disable-devtool.min.js#use'
|
src='https://cdn.jsdelivr.net/npm/disable-devtool@0.1.12/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>
|
||||||
|
@ -105,7 +105,7 @@ declare interface optionStatic {
|
|||||||
md5?: string; // Bypass the disabled md5 value, see 3.2 for details, the bypass disable is not enabled by default
|
md5?: string; // Bypass the disabled md5 value, see 3.2 for details, the bypass disable is not enabled by default
|
||||||
url?: string; // Jump to the page when closing the page fails, the default value is localhost
|
url?: string; // Jump to the page when closing the page fails, the default value is localhost
|
||||||
tkName?: string; // Bypass the url parameter name when disabled, the default is ddtk
|
tkName?: string; // Bypass the url parameter name when disabled, the default is ddtk
|
||||||
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
|
ondevtoolopen?(type: DetectorType, next: Function): 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
|
interval?: number; // Timer interval is 200ms by default
|
||||||
disableMenu?: boolean; // Whether to disable the right-click menu The default is true
|
disableMenu?: boolean; // Whether to disable the right-click menu The default is true
|
||||||
clearIntervalWhenDevOpenTrigger?: boolean; // Whether to stop monitoring after triggering The default is false
|
clearIntervalWhenDevOpenTrigger?: boolean; // Whether to stop monitoring after triggering The default is false
|
||||||
|
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
2
npm/index.d.ts
vendored
2
npm/index.d.ts
vendored
@ -4,7 +4,7 @@ declare interface optionStatic {
|
|||||||
md5?: string; // 绕过禁用的md5值,详情见3.2,默认不启用绕过禁用
|
md5?: string; // 绕过禁用的md5值,详情见3.2,默认不启用绕过禁用
|
||||||
url?: string; // 关闭页面失败时的跳转页面,默认值为localhost
|
url?: string; // 关闭页面失败时的跳转页面,默认值为localhost
|
||||||
tkName?: string; // 绕过禁用时的url参数名称,默认为 ddtk
|
tkName?: string; // 绕过禁用时的url参数名称,默认为 ddtk
|
||||||
ondevtoolopen?(type: DETECTOR_TYPE): void; // 开发者面板打开的回调,启用时url参数无效
|
ondevtoolopen?(type: DETECTOR_TYPE, next: Function): void; // 开发者面板打开的回调,启用时url参数无效
|
||||||
interval?: number; // 定时器的时间间隔 默认200ms
|
interval?: number; // 定时器的时间间隔 默认200ms
|
||||||
disableMenu?: boolean; // 是否禁用右键菜单 默认为true
|
disableMenu?: boolean; // 是否禁用右键菜单 默认为true
|
||||||
stopIntervalTime?: number; // 在移动端时取消监视的等待时长
|
stopIntervalTime?: number; // 在移动端时取消监视的等待时长
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "disable-devtool",
|
"name": "disable-devtool",
|
||||||
"version": "0.1.11",
|
"version": "0.1.12",
|
||||||
"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",
|
||||||
|
14154
package-lock.json
generated
14154
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "disable-devtool",
|
"name": "disable-devtool",
|
||||||
"version": "0.1.11",
|
"version": "0.1.12",
|
||||||
"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,7 +1,6 @@
|
|||||||
import disableDevtool from '../src';
|
import disableDevtool from '../src';
|
||||||
// import disableDevtool from '../npm';
|
// import disableDevtool from '../npm';
|
||||||
|
|
||||||
// debugger;
|
|
||||||
|
|
||||||
disableDevtool({
|
disableDevtool({
|
||||||
md5: '0b9e05caf5000360ec1c263335bd83fe', // ddtk
|
md5: '0b9e05caf5000360ec1c263335bd83fe', // ddtk
|
||||||
@ -9,8 +8,10 @@ disableDevtool({
|
|||||||
ondevtoolopen: (type) => {
|
ondevtoolopen: (type) => {
|
||||||
// window.location.href = 'https://www.qq.com';
|
// window.location.href = 'https://www.qq.com';
|
||||||
document.body.innerHTML = 'devtool opened!; type =' + type;
|
document.body.innerHTML = 'devtool opened!; type =' + type;
|
||||||
history.back();
|
// next();
|
||||||
|
// console.log(next);
|
||||||
},
|
},
|
||||||
|
clearIntervalWhenDevOpenTrigger: true,
|
||||||
interval: 1000,
|
interval: 1000,
|
||||||
// tkName: 'ddtk',
|
// tkName: 'ddtk',
|
||||||
disableMenu: false,
|
disableMenu: false,
|
||||||
@ -19,4 +20,15 @@ disableDevtool({
|
|||||||
});
|
});
|
||||||
|
|
||||||
// console.log(disableDevtool.version);
|
// console.log(disableDevtool.version);
|
||||||
// console.log(disableDevtool.md5('xx'));
|
// console.log(disableDevtool.md5('xx'));
|
||||||
|
|
||||||
|
|
||||||
|
// import {log} from '../src/log';
|
||||||
|
|
||||||
|
// setTimeout(() => {
|
||||||
|
// log(111);
|
||||||
|
// debugger;
|
||||||
|
// }, 3000);
|
||||||
|
|
||||||
|
|
||||||
|
// window.log = log;
|
@ -7,9 +7,9 @@
|
|||||||
* @Description: Coding something
|
* @Description: Coding something
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {registInterval} from '../interval';
|
import {registInterval} from '../utils/interval';
|
||||||
import {DETECTOR_TYPE, triggerOnDevOpen} from './detector';
|
import {DETECTOR_TYPE, triggerOnDevOpen} from './detector';
|
||||||
import {log} from '../util';
|
import {clearLog, log} from '../utils/log';
|
||||||
|
|
||||||
export default function detector () {
|
export default function detector () {
|
||||||
let count = 0;
|
let count = 0;
|
||||||
@ -22,7 +22,7 @@ export default function detector () {
|
|||||||
const checkIsOpen = () => {
|
const checkIsOpen = () => {
|
||||||
count = 0;
|
count = 0;
|
||||||
log(date);
|
log(date);
|
||||||
console.clear();
|
clearLog();
|
||||||
if (count >= 2) {
|
if (count >= 2) {
|
||||||
triggerOnDevOpen(DETECTOR_TYPE.DATE_TO_STRING);
|
triggerOnDevOpen(DETECTOR_TYPE.DATE_TO_STRING);
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* @Description: Coding something
|
* @Description: Coding something
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {registInterval} from '../interval';
|
import {registInterval} from '../utils/interval';
|
||||||
import {DETECTOR_TYPE, triggerOnDevOpen} from './detector';
|
import {DETECTOR_TYPE, triggerOnDevOpen} from './detector';
|
||||||
|
|
||||||
export default function detector () {
|
export default function detector () {
|
||||||
|
@ -2,12 +2,12 @@
|
|||||||
* @Author: theajack
|
* @Author: theajack
|
||||||
* @Date: 2021-07-24 23:15:49
|
* @Date: 2021-07-24 23:15:49
|
||||||
* @LastEditor: theajack
|
* @LastEditor: theajack
|
||||||
* @LastEditTime: 2021-07-25 16:46:36
|
* @LastEditTime: 2021-12-24 13:23:55
|
||||||
* @Description: Coding something
|
* @Description: Coding something
|
||||||
*/
|
*/
|
||||||
import {DETECTOR_TYPE, triggerOnDevOpen} from './detector';
|
import {DETECTOR_TYPE, triggerOnDevOpen} from './detector';
|
||||||
import {registInterval} from '../interval';
|
import {registInterval} from '../utils/interval';
|
||||||
import {log} from '../util';
|
import {log} from '../utils/log';
|
||||||
|
|
||||||
export default function detector () {
|
export default function detector () {
|
||||||
const div = document.createElement('div');
|
const div = document.createElement('div');
|
||||||
|
@ -2,11 +2,11 @@
|
|||||||
* @Author: theajack
|
* @Author: theajack
|
||||||
* @Date: 2021-07-24 23:16:34
|
* @Date: 2021-07-24 23:16:34
|
||||||
* @LastEditor: theajack
|
* @LastEditor: theajack
|
||||||
* @LastEditTime: 2021-11-16 08:48:48
|
* @LastEditTime: 2021-12-24 15:17:10
|
||||||
* @Description: Coding something
|
* @Description: Coding something
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {config} from '../config';
|
import {config} from '../utils/config';
|
||||||
import RegToStringDetector from './reg-to-string';
|
import RegToStringDetector from './reg-to-string';
|
||||||
import DefineIdDetector from './define-id';
|
import DefineIdDetector from './define-id';
|
||||||
import SizeDetector from './size';
|
import SizeDetector from './size';
|
||||||
@ -14,7 +14,8 @@ import DateToStringDetector from './date-to-string';
|
|||||||
import FuncToStringDetector from './func-to-string';
|
import FuncToStringDetector from './func-to-string';
|
||||||
// import DebuggerDetector from './debugger'; // 会debuger显示devtool
|
// import DebuggerDetector from './debugger'; // 会debuger显示devtool
|
||||||
// import LogTimeDetector from './log-time'; // 不准确 容易误伤
|
// import LogTimeDetector from './log-time'; // 不准确 容易误伤
|
||||||
import {clearDDInterval, clearDDTimeout} from '../interval';
|
import {clearDDInterval, clearDDTimeout} from '../utils/interval';
|
||||||
|
import {closeWindow} from '../utils/close-window';
|
||||||
|
|
||||||
const detectorList = [];
|
const detectorList = [];
|
||||||
|
|
||||||
@ -60,5 +61,5 @@ export function triggerOnDevOpen (type = DETECTOR_TYPE.UNKONW) {
|
|||||||
clearDDInterval();
|
clearDDInterval();
|
||||||
}
|
}
|
||||||
clearDDTimeout();
|
clearDDTimeout();
|
||||||
config.ondevtoolopen(type);
|
config.ondevtoolopen(type, closeWindow);
|
||||||
}
|
}
|
@ -7,9 +7,9 @@
|
|||||||
* @Description: Coding something
|
* @Description: Coding something
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {registInterval} from '../interval';
|
import {registInterval} from '../utils/interval';
|
||||||
import {DETECTOR_TYPE, triggerOnDevOpen} from './detector';
|
import {DETECTOR_TYPE, triggerOnDevOpen} from './detector';
|
||||||
import {log} from '../util';
|
import {log, clearLog} from '../utils/log';
|
||||||
|
|
||||||
export default function detector () {
|
export default function detector () {
|
||||||
let count = 0;
|
let count = 0;
|
||||||
@ -22,7 +22,7 @@ export default function detector () {
|
|||||||
const checkIsOpen = () => {
|
const checkIsOpen = () => {
|
||||||
count = 0;
|
count = 0;
|
||||||
log(func);
|
log(func);
|
||||||
console.clear();
|
clearLog();
|
||||||
if (count >= 2) {
|
if (count >= 2) {
|
||||||
triggerOnDevOpen(DETECTOR_TYPE.FUNC_TO_STRING);
|
triggerOnDevOpen(DETECTOR_TYPE.FUNC_TO_STRING);
|
||||||
}
|
}
|
||||||
|
@ -2,20 +2,20 @@
|
|||||||
* @Author: theajack
|
* @Author: theajack
|
||||||
* @Date: 2021-07-24 23:15:22
|
* @Date: 2021-07-24 23:15:22
|
||||||
* @LastEditor: theajack
|
* @LastEditor: theajack
|
||||||
* @LastEditTime: 2021-12-09 08:00:47
|
* @LastEditTime: 2021-12-24 14:07:31
|
||||||
* @Description: Coding something
|
* @Description: Coding something
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// import {DETECTOR_TYPE, triggerOnDevOpen} from './detector';
|
// import {DETECTOR_TYPE, triggerOnDevOpen} from './detector';
|
||||||
// import {registInterval} from '../interval';
|
// import {registInterval} from '../utils/interval';
|
||||||
// import {log} from '../util';
|
// import {log, clearLog} from '../utils/log';
|
||||||
|
|
||||||
// function logTime () {
|
// function logTime () {
|
||||||
// const d = new Date();
|
// const d = new Date();
|
||||||
// for (let i = 0; i < 2000; i++) {
|
// for (let i = 0; i < 2000; i++) {
|
||||||
// log(1);
|
// log(1);
|
||||||
// }
|
// }
|
||||||
// console.clear();
|
// clearLog();
|
||||||
// if (new Date() - d > 100) {
|
// if (new Date() - d > 100) {
|
||||||
// console.warn(new Date() - d);
|
// console.warn(new Date() - d);
|
||||||
// triggerOnDevOpen(DETECTOR_TYPE.LOG_TIME);
|
// triggerOnDevOpen(DETECTOR_TYPE.LOG_TIME);
|
||||||
|
@ -2,18 +2,19 @@
|
|||||||
* @Author: theajack
|
* @Author: theajack
|
||||||
* @Date: 2021-07-24 23:15:01
|
* @Date: 2021-07-24 23:15:01
|
||||||
* @LastEditor: theajack
|
* @LastEditor: theajack
|
||||||
* @LastEditTime: 2021-12-09 07:58:29
|
* @LastEditTime: 2021-12-24 13:19:18
|
||||||
* @Description: Coding something
|
* @Description: Coding something
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {registInterval} from '../interval';
|
import {registInterval} from '../utils/interval';
|
||||||
import {isFirefox, isQQBrowser, log} from '../util';
|
import {isFirefox, isQQBrowser} from '../utils/util';
|
||||||
|
import {log} from '../utils/log';
|
||||||
import {DETECTOR_TYPE, triggerOnDevOpen} from './detector';
|
import {DETECTOR_TYPE, triggerOnDevOpen} from './detector';
|
||||||
|
|
||||||
// 这个方法在chrome 中无论是否打开都会触发
|
// 这个方法在chrome 中无论是否打开都会触发
|
||||||
export default function detector () {
|
export default function detector () {
|
||||||
const isQQ = isQQBrowser();
|
const isQQ = isQQBrowser;
|
||||||
const isFF = isFirefox();
|
const isFF = isFirefox;
|
||||||
if (!isQQ && !isFF) return;
|
if (!isQQ && !isFF) return;
|
||||||
let lastTime = 0;
|
let lastTime = 0;
|
||||||
const reg = /./;
|
const reg = /./;
|
||||||
|
@ -2,12 +2,12 @@
|
|||||||
* @Author: theajack
|
* @Author: theajack
|
||||||
* @Date: 2021-07-24 23:15:54
|
* @Date: 2021-07-24 23:15:54
|
||||||
* @LastEditor: theajack
|
* @LastEditor: theajack
|
||||||
* @LastEditTime: 2021-11-26 11:08:33
|
* @LastEditTime: 2021-12-24 15:18:29
|
||||||
* @Description: Coding something
|
* @Description: Coding something
|
||||||
* @FilePath: \disable-devtool\src\detector\size.js
|
* @FilePath: /disable-devtool/src/detector/size.js
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {isInIframe} from '../util';
|
import {isInIframe} from '../utils/util';
|
||||||
import {DETECTOR_TYPE, triggerOnDevOpen} from './detector';
|
import {DETECTOR_TYPE, triggerOnDevOpen} from './detector';
|
||||||
|
|
||||||
function checkWindowSizeUneven () {
|
function checkWindowSizeUneven () {
|
||||||
@ -39,7 +39,7 @@ function countScreenZoomRatio () {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export default function detector () {
|
export default function detector () {
|
||||||
if (isInIframe()) {
|
if (isInIframe) {
|
||||||
console.warn('SizeDetector is disabled in IFrame');
|
console.warn('SizeDetector is disabled in IFrame');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
2
src/index.d.ts
vendored
2
src/index.d.ts
vendored
@ -4,7 +4,7 @@ declare interface optionStatic {
|
|||||||
md5?: string; // 绕过禁用的md5值,详情见3.2,默认不启用绕过禁用
|
md5?: string; // 绕过禁用的md5值,详情见3.2,默认不启用绕过禁用
|
||||||
url?: string; // 关闭页面失败时的跳转页面,默认值为localhost
|
url?: string; // 关闭页面失败时的跳转页面,默认值为localhost
|
||||||
tkName?: string; // 绕过禁用时的url参数名称,默认为 ddtk
|
tkName?: string; // 绕过禁用时的url参数名称,默认为 ddtk
|
||||||
ondevtoolopen?(type: DETECTOR_TYPE): void; // 开发者面板打开的回调,启用时url参数无效
|
ondevtoolopen?(type: DETECTOR_TYPE, next: Function): void; // 开发者面板打开的回调,启用时url参数无效
|
||||||
interval?: number; // 定时器的时间间隔 默认200ms
|
interval?: number; // 定时器的时间间隔 默认200ms
|
||||||
disableMenu?: boolean; // 是否禁用右键菜单 默认为true
|
disableMenu?: boolean; // 是否禁用右键菜单 默认为true
|
||||||
stopIntervalTime?: number; // 在移动端时取消监视的等待时长
|
stopIntervalTime?: number; // 在移动端时取消监视的等待时长
|
||||||
|
@ -1,27 +0,0 @@
|
|||||||
import {config} from './config';
|
|
||||||
import {isMacOs} from './util';
|
|
||||||
|
|
||||||
export function disableKeyAndMenu () {
|
|
||||||
let key1 = 'shiftKey', key2 = 'ctrlKey';
|
|
||||||
if (isMacOs()) {
|
|
||||||
key1 = 'metaKey';
|
|
||||||
key2 = 'altKey';
|
|
||||||
}
|
|
||||||
window.addEventListener('keydown', (e) => {
|
|
||||||
e = e || window.event;
|
|
||||||
const keyCode = e.keyCode || e.which;
|
|
||||||
if (keyCode === 123 || (e[key1] && e[key2] && e.keyCode === 73)) {
|
|
||||||
e.returnValue = false;
|
|
||||||
e.preventDefault();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}, true);
|
|
||||||
if (config.disableMenu) {
|
|
||||||
window.addEventListener('contextmenu', (e) => {
|
|
||||||
e = e || window.event;
|
|
||||||
e.returnValue = false;
|
|
||||||
e.preventDefault();
|
|
||||||
return false;
|
|
||||||
}, true);
|
|
||||||
}
|
|
||||||
}
|
|
11
src/main.js
11
src/main.js
@ -1,8 +1,9 @@
|
|||||||
import {disableKeyAndMenu} from './key-menu';
|
import './utils/log';
|
||||||
import {initInterval} from './interval';
|
import {disableKeyAndMenu} from './utils/key-menu';
|
||||||
import {formatName, getUrlParam} from './util';
|
import {initInterval} from './utils/interval';
|
||||||
import {mergeConfig, config} from './config';
|
import {formatName, getUrlParam} from './utils/util';
|
||||||
import md5 from './md5';
|
import {mergeConfig, config} from './utils/config';
|
||||||
|
import md5 from './utils/md5';
|
||||||
import version from './version';
|
import version from './version';
|
||||||
import {DETECTOR_TYPE, initDetectors} from './detector/detector';
|
import {DETECTOR_TYPE, initDetectors} from './detector/detector';
|
||||||
|
|
||||||
|
31
src/utils/close-window.js
Normal file
31
src/utils/close-window.js
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
* @Author: tackchen
|
||||||
|
* @Date: 2021-12-24 15:14:06
|
||||||
|
* @LastEditors: tackchen
|
||||||
|
* @LastEditTime: 2021-12-24 15:14:25
|
||||||
|
* @FilePath: /disable-devtool/src/close-window.js
|
||||||
|
* @Description: Coding something
|
||||||
|
*/
|
||||||
|
import {config} from './config';
|
||||||
|
import {clearDDInterval} from './interval';
|
||||||
|
|
||||||
|
export function closeWindow () {
|
||||||
|
clearDDInterval();
|
||||||
|
if (config.url) {
|
||||||
|
window.location.href = config.url;
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
window.opener = null;
|
||||||
|
window.open('', '_self');
|
||||||
|
// 需要是由js跳转到这个页面才可以关闭这个页面
|
||||||
|
window.close();
|
||||||
|
window.history.back();
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e);
|
||||||
|
}
|
||||||
|
setTimeout(() => {
|
||||||
|
// 否则执行跳转到 url
|
||||||
|
window.location.href = `https://tackchen.gitee.io/404.html?h=${encodeURIComponent(location.host)}`;
|
||||||
|
}, 500);
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
import {closeWindow} from './util';
|
import {closeWindow} from './close-window';
|
||||||
|
|
||||||
export const config = {
|
export const config = {
|
||||||
md5: '',
|
md5: '',
|
||||||
@ -6,7 +6,7 @@ export const config = {
|
|||||||
url: '',
|
url: '',
|
||||||
tkName: 'ddtk',
|
tkName: 'ddtk',
|
||||||
interval: 200,
|
interval: 200,
|
||||||
disableMenu: true, // 该参数ie下无效,ie 右键菜单会阻塞线程影响debug延迟计算 禁用右键菜单
|
disableMenu: true, // 是否禁用右键菜单
|
||||||
stopIntervalTime: 5000, // 在移动端时取消监视的等待时长
|
stopIntervalTime: 5000, // 在移动端时取消监视的等待时长
|
||||||
clearIntervalWhenDevOpenTrigger: false, // 是否在触发之后停止监控
|
clearIntervalWhenDevOpenTrigger: false, // 是否在触发之后停止监控
|
||||||
detectors: 'all',
|
detectors: 'all',
|
@ -1,4 +1,5 @@
|
|||||||
import {config} from './config';
|
import {config} from './config';
|
||||||
|
import {clearLog} from './log';
|
||||||
import {hackAlert, isPC, onPageShowHide} from './util';
|
import {hackAlert, isPC, onPageShowHide} from './util';
|
||||||
|
|
||||||
let interval = null, timer = null;
|
let interval = null, timer = null;
|
||||||
@ -15,7 +16,7 @@ export function initInterval () {
|
|||||||
interval = window.setInterval(() => {
|
interval = window.setInterval(() => {
|
||||||
if (_pause) return;
|
if (_pause) return;
|
||||||
calls.forEach(fn => {fn(time++);});
|
calls.forEach(fn => {fn(time++);});
|
||||||
console.clear();
|
clearLog();
|
||||||
}, config.interval);
|
}, config.interval);
|
||||||
// stopIntervalTime 之后判断 如果不是pc去掉定时器interval,为了优化移动端的性能
|
// stopIntervalTime 之后判断 如果不是pc去掉定时器interval,为了优化移动端的性能
|
||||||
// 如果控制面板被打开了该定时器timer会被清除
|
// 如果控制面板被打开了该定时器timer会被清除
|
38
src/utils/key-menu.js
Normal file
38
src/utils/key-menu.js
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
import {config} from './config';
|
||||||
|
import {isMacOs} from './util';
|
||||||
|
|
||||||
|
export function disableKeyAndMenu () {
|
||||||
|
// let key1 = 'shiftKey', key2 = 'ctrlKey';
|
||||||
|
// 'metaKey'; // mac 的 commond
|
||||||
|
// 'altKey'; // mac 的 option
|
||||||
|
const KEY = {I: 73, U: 85, S: 83, F12: 123};
|
||||||
|
|
||||||
|
const isOpenDevToolKey = isMacOs ?
|
||||||
|
((e, code) => (e.metaKey && e.altKey && code === KEY.I)) :
|
||||||
|
((e, code) => (e.ctrlKey && e.shiftKey && code === KEY.I));
|
||||||
|
const isViewSourceCodeKey = isMacOs ?
|
||||||
|
((e, code) => (e.metaKey && e.altKey && code === KEY.U) || (e.metaKey && code === KEY.S)) :
|
||||||
|
((e, code) => (e.ctrlKey && (code === KEY.S || code === KEY.U)));
|
||||||
|
|
||||||
|
window.addEventListener('keydown', (e) => {
|
||||||
|
e = e || window.event;
|
||||||
|
const keyCode = e.keyCode || e.which;
|
||||||
|
if (
|
||||||
|
keyCode === KEY.F12 || // 禁用f12
|
||||||
|
isOpenDevToolKey(e, keyCode) || // 禁用 ctrl + shift + i
|
||||||
|
isViewSourceCodeKey(e, keyCode) // 禁用 ctrl + u 和 ctrl + s 查看和保存源码
|
||||||
|
) {
|
||||||
|
e.returnValue = false;
|
||||||
|
e.preventDefault();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}, true);
|
||||||
|
if (config.disableMenu) {
|
||||||
|
window.addEventListener('contextmenu', (e) => {
|
||||||
|
e = e || window.event;
|
||||||
|
e.returnValue = false;
|
||||||
|
e.preventDefault();
|
||||||
|
return false;
|
||||||
|
}, true);
|
||||||
|
}
|
||||||
|
}
|
24
src/utils/log.js
Normal file
24
src/utils/log.js
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
/*
|
||||||
|
* @Author: tackchen
|
||||||
|
* @Date: 2021-12-24 13:18:23
|
||||||
|
* @LastEditors: tackchen
|
||||||
|
* @FilePath: /disable-devtool/src/log.js
|
||||||
|
* @Description: Coding something
|
||||||
|
*/
|
||||||
|
import {isIE} from './util';
|
||||||
|
|
||||||
|
const console = window.console || {
|
||||||
|
log: function () {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const log = (() => {
|
||||||
|
// ie 不支持缓存使用 log等方法
|
||||||
|
return isIE ? ((...args) => {return console.log(...args);}) : console.log;
|
||||||
|
})();
|
||||||
|
|
||||||
|
export const clearLog = (() => {
|
||||||
|
// ie 不支持缓存使用 log等方法
|
||||||
|
return isIE ? (() => {return console.clear();}) : console.clear;
|
||||||
|
})();
|
@ -1,31 +1,7 @@
|
|||||||
import {config} from './config';
|
|
||||||
import {clearDDInterval} from './interval';
|
|
||||||
|
|
||||||
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());
|
||||||
}
|
}
|
||||||
|
|
||||||
export function closeWindow () {
|
|
||||||
clearDDInterval();
|
|
||||||
if (config.url) {
|
|
||||||
window.location.href = config.url;
|
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
window.opener = null;
|
|
||||||
window.open('', '_self');
|
|
||||||
// 需要是由js跳转到这个页面才可以关闭这个页面
|
|
||||||
window.close();
|
|
||||||
window.history.back();
|
|
||||||
} catch (e) {
|
|
||||||
console.log(e);
|
|
||||||
}
|
|
||||||
setTimeout(() => {
|
|
||||||
// 否则执行跳转到 url
|
|
||||||
window.location.href = `https://tackchen.gitee.io/404.html?h=${encodeURIComponent(location.host)}`;
|
|
||||||
}, 500);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getNowTime () {
|
export function getNowTime () {
|
||||||
return new Date().getTime();
|
return new Date().getTime();
|
||||||
}
|
}
|
||||||
@ -107,28 +83,24 @@ export function hackAlert (before, after) {
|
|||||||
window.prompt = mod(_prompt);
|
window.prompt = mod(_prompt);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isQQBrowser () {
|
|
||||||
return hasUaName('qqbrowser');
|
|
||||||
}
|
|
||||||
|
|
||||||
export function isFirefox () {
|
|
||||||
return hasUaName('firefox');
|
|
||||||
}
|
|
||||||
|
|
||||||
export function isMacOs () {
|
|
||||||
return hasUaName('macintosh');
|
|
||||||
}
|
|
||||||
|
|
||||||
function hasUaName (name) {
|
function hasUaName (name) {
|
||||||
return navigator.userAgent.toLocaleLowerCase().indexOf(name) !== -1;
|
return navigator.userAgent.toLocaleLowerCase().indexOf(name) !== -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isInIframe () {
|
export const isInIframe = (() => {
|
||||||
try {
|
try {
|
||||||
return window.self !== window.top;
|
return window.self !== window.top;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
})();
|
||||||
|
|
||||||
export const log = console.log;
|
export const isQQBrowser = hasUaName('qqbrowser');
|
||||||
|
|
||||||
|
export const isFirefox = hasUaName('firefox');
|
||||||
|
|
||||||
|
export const isMacOs = hasUaName('macintosh');
|
||||||
|
|
||||||
|
export const isOldEdge = hasUaName('edge') && !hasUaName('chrome');
|
||||||
|
|
||||||
|
export const isIE = isOldEdge || hasUaName('trident') || hasUaName('msie');
|
@ -1 +1 @@
|
|||||||
export default '0.1.11';
|
export default '0.1.12';
|
Loading…
x
Reference in New Issue
Block a user