From c578a641616ab16015698367dd5afd8da6706342 Mon Sep 17 00:00:00 2001
From: theajack <1506282385@qq.com>
Date: Sun, 24 Jan 2021 15:25:04 +0800
Subject: [PATCH] feat: 0.1.0 check version.md for details
---
README.cn.md | 8 ++---
README.md | 8 ++---
helper/copy-to-npm.js | 2 +-
helper/version.md | 7 +++-
index.html | 7 ++--
npm/README.cn.md | 8 ++---
npm/README.md | 8 ++---
npm/disable-devtool.min.js | 2 +-
npm/index.d.ts | 3 +-
npm/package.json | 11 +++----
package.json | 6 ++--
public/main.js | 6 ++--
src/config.js | 1 -
src/index.d.ts | 3 +-
src/interval.js | 1 -
src/key-menu.js | 3 +-
src/main.js | 66 ++++++++++++++++++++------------------
src/util.js | 14 +++++++-
src/version.js | 2 +-
19 files changed, 82 insertions(+), 84 deletions(-)
diff --git a/README.cn.md b/README.cn.md
index 8d9b538..d9535e1 100644
--- a/README.cn.md
+++ b/README.cn.md
@@ -61,9 +61,9 @@ disable-devtool 可以禁用所有一切可以进入开发者工具的方法,
2. 禁用 f12 和 ctrl+shift+i 快捷键
3. 支持识别从浏览器菜单栏打开开发者工具并关闭当前页面
4. 开发者可以绕过禁用 (url参数使用tk配合md5加密)
-5. 支持几乎所有浏览器(包含IE)
+5. 支持几乎所有浏览器(IE,360,qq浏览器,FireFox,Chrome,Edge...)
6. 高度可配置
-7. 使用极简、体积小巧 (仅6kb)
+7. 使用极简、体积小巧 (仅7kb)
8. 支持npm引用和script标签引用(属性配置)
9. 识别真移动端与浏览器开发者工具设置插件伪造的移动端,为移动端节省性能
@@ -91,15 +91,12 @@ declare interface optionStatic {
url?: string; // 关闭页面失败时的跳转页面,默认值为localhost
tkName?: string; // 绕过禁用时的url参数名称,默认为 ddtk
ondevtoolopen?(): void; // 开发者面板打开的回调,启用时url参数无效
- debugDelay?: number; // debug模式时的延迟 默认200ms
interval?: number; // 定时器的时间间隔 默认200ms
disableMenu?: boolean; // 是否禁用右键菜单 默认为true
stopIntervalTime?: number; // 在移动端时取消监视的等待时长
}
```
-备注:disableMenu参数在ie下无效,因为ie下右键会阻塞主进程,且无法监听
-
### 3.2 md5 与 tk 绕过禁用
该库中使用 key 与 md5 配合的方式使得开发者可以在线上绕过禁用。
@@ -123,7 +120,6 @@ disableDevtool.md5('xxx');
md5='xxx'
url='xxx'
tk-name='xxx'
- debug-delay='xxx'
interval='xxx'
disable-menu='xxx'
>
diff --git a/README.md b/README.md
index 064e23b..22126f0 100644
--- a/README.md
+++ b/README.md
@@ -60,9 +60,9 @@ The library has the following features:
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 disablement (use tk and md5 encryption for url parameters)
-5. Support almost all browsers (Include IE)
+5. Support almost all browsers (IE,360,qq browser,FireFox,Chrome,Edge...)
6. Highly configurable
-7. Minimal use, small size (only 6kb)
+7. Minimal use, small size (only 7kb)
8. Support npm reference and script tag reference (attribute configuration)
9. Identify the real mobile terminal and browser developer tool settings plug-in forged mobile terminal, saving performance for the mobile terminal
@@ -90,15 +90,12 @@ declare interface optionStatic {
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
ondevtoolopen?(): void; // Callback for opening the developer panel, the url parameter is invalid when enabled
- debugDelay?: number; // The delay in debug mode 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
stopIntervalTime?: number; // Waiting time to cancel monitoring on mobile
}
```
-Note: The disableMenu parameter is invalid under ie, because the right button under ie will block the main process and cannot monitor
-
### 3.2 md5 and tk bypass disable
The combination of key and md5 in the library allows developers to bypass the disabling online.
@@ -122,7 +119,6 @@ disableDevtool.md5('xxx');
md5='xxx'
url='xxx'
tk-name='xxx'
- debug-delay='xxx'
interval='xxx'
disable-menu='xxx'
>
diff --git a/helper/copy-to-npm.js b/helper/copy-to-npm.js
index 784676a..a5abfd2 100644
--- a/helper/copy-to-npm.js
+++ b/helper/copy-to-npm.js
@@ -13,7 +13,7 @@ function copyPkg () {
let npmPkg = util.pick({
target: pkg,
attrs: [
- 'name', 'version', 'description', 'main', 'scripts', 'unpkg', 'jsdelivr',
+ 'name', 'version', 'description', 'main', 'unpkg', 'jsdelivr',
'typings', 'repository', 'keywords', 'author', 'license', 'bugs', 'homepage'
]
});
diff --git a/helper/version.md b/helper/version.md
index 1ba45f1..a11d2c5 100644
--- a/helper/version.md
+++ b/helper/version.md
@@ -7,7 +7,7 @@
4. 开发者可以绕过禁用 (url参数使用tk配合md5加密)
5. 支持几乎所有浏览器
6. 高度可配置
-7. 使用极简、体积小巧 (仅6kb)
+7. 使用极简、体积小巧 (仅7kb)
8. 支持npm引用和script标签引用(属性配置)
## 0.0.2
@@ -30,3 +30,8 @@
1. 对于标签属性配置,移除id='disable-devtool' 条件,使用 disable-devtool-auto属性
2. 修改readme
+## 0.1.0
+1. 修复firefox和qq浏览器下无效的问题
+2. 启用 disableMenu 配置
+3. 去除内部debug逻辑
+4. 增加默认跳转的404页面
\ No newline at end of file
diff --git a/index.html b/index.html
index 4975374..2f594de 100644
--- a/index.html
+++ b/index.html
@@ -97,9 +97,9 @@ disableDevtool();
Disable f12 and ctrl+shift+i shortcuts
Support recognition to open the developer tools from the browser menu bar and close the current page
Developers can bypass the disablement (use tk and md5 encryption for url parameters)
- Support almost all browsers (Include IE)
+ Support almost all browsers (IE,360,qq browser,FireFox,Chrome,Edge...)
Highly configurable
- Minimal use, small size (only 6kb)
+ Minimal use, small size (only 7kb)
Support npm reference and script tag reference (attribute configuration)
Identify the real mobile terminal and browser developer tool settings plug-in forged mobile terminal, saving performance for the mobile terminal
@@ -122,9 +122,9 @@ disableDevtool(options);
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
ondevtoolopen?(): void; // Callback for opening the developer panel, the url parameter is invalid when enabled
- debugDelay?: number; // The delay in debug mode 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
+ stopIntervalTime?: number; // Waiting time to cancel monitoring on mobile
}
3.2 md5 and tk bypass disable
@@ -156,7 +156,6 @@ disableDevtool(options);
md5='xxx'
url='xxx'
tk-name='xxx'
- debug-delay='xxx'
interval='xxx'
disable-menu='xxx'>
</script>
diff --git a/npm/README.cn.md b/npm/README.cn.md
index 8d9b538..d9535e1 100644
--- a/npm/README.cn.md
+++ b/npm/README.cn.md
@@ -61,9 +61,9 @@ disable-devtool 可以禁用所有一切可以进入开发者工具的方法,
2. 禁用 f12 和 ctrl+shift+i 快捷键
3. 支持识别从浏览器菜单栏打开开发者工具并关闭当前页面
4. 开发者可以绕过禁用 (url参数使用tk配合md5加密)
-5. 支持几乎所有浏览器(包含IE)
+5. 支持几乎所有浏览器(IE,360,qq浏览器,FireFox,Chrome,Edge...)
6. 高度可配置
-7. 使用极简、体积小巧 (仅6kb)
+7. 使用极简、体积小巧 (仅7kb)
8. 支持npm引用和script标签引用(属性配置)
9. 识别真移动端与浏览器开发者工具设置插件伪造的移动端,为移动端节省性能
@@ -91,15 +91,12 @@ declare interface optionStatic {
url?: string; // 关闭页面失败时的跳转页面,默认值为localhost
tkName?: string; // 绕过禁用时的url参数名称,默认为 ddtk
ondevtoolopen?(): void; // 开发者面板打开的回调,启用时url参数无效
- debugDelay?: number; // debug模式时的延迟 默认200ms
interval?: number; // 定时器的时间间隔 默认200ms
disableMenu?: boolean; // 是否禁用右键菜单 默认为true
stopIntervalTime?: number; // 在移动端时取消监视的等待时长
}
```
-备注:disableMenu参数在ie下无效,因为ie下右键会阻塞主进程,且无法监听
-
### 3.2 md5 与 tk 绕过禁用
该库中使用 key 与 md5 配合的方式使得开发者可以在线上绕过禁用。
@@ -123,7 +120,6 @@ disableDevtool.md5('xxx');
md5='xxx'
url='xxx'
tk-name='xxx'
- debug-delay='xxx'
interval='xxx'
disable-menu='xxx'
>
diff --git a/npm/README.md b/npm/README.md
index 064e23b..22126f0 100644
--- a/npm/README.md
+++ b/npm/README.md
@@ -60,9 +60,9 @@ The library has the following features:
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 disablement (use tk and md5 encryption for url parameters)
-5. Support almost all browsers (Include IE)
+5. Support almost all browsers (IE,360,qq browser,FireFox,Chrome,Edge...)
6. Highly configurable
-7. Minimal use, small size (only 6kb)
+7. Minimal use, small size (only 7kb)
8. Support npm reference and script tag reference (attribute configuration)
9. Identify the real mobile terminal and browser developer tool settings plug-in forged mobile terminal, saving performance for the mobile terminal
@@ -90,15 +90,12 @@ declare interface optionStatic {
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
ondevtoolopen?(): void; // Callback for opening the developer panel, the url parameter is invalid when enabled
- debugDelay?: number; // The delay in debug mode 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
stopIntervalTime?: number; // Waiting time to cancel monitoring on mobile
}
```
-Note: The disableMenu parameter is invalid under ie, because the right button under ie will block the main process and cannot monitor
-
### 3.2 md5 and tk bypass disable
The combination of key and md5 in the library allows developers to bypass the disabling online.
@@ -122,7 +119,6 @@ disableDevtool.md5('xxx');
md5='xxx'
url='xxx'
tk-name='xxx'
- debug-delay='xxx'
interval='xxx'
disable-menu='xxx'
>
diff --git a/npm/disable-devtool.min.js b/npm/disable-devtool.min.js
index ddc87b3..85ef5ac 100644
--- a/npm/disable-devtool.min.js
+++ b/npm/disable-devtool.min.js
@@ -1 +1 @@
-!function(n,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.DisableDevtool=e():n.DisableDevtool=e()}(this,(function(){return function(n){var e={};function t(o){if(e[o])return e[o].exports;var i=e[o]={i:o,l:!1,exports:{}};return n[o].call(i.exports,i,i.exports,t),i.l=!0,i.exports}return t.m=n,t.c=e,t.d=function(n,e,o){t.o(n,e)||Object.defineProperty(n,e,{enumerable:!0,get:o})},t.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})},t.t=function(n,e){if(1&e&&(n=t(n)),8&e)return n;if(4&e&&"object"==typeof n&&n&&n.__esModule)return n;var o=Object.create(null);if(t.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:n}),2&e&&"string"!=typeof n)for(var i in n)t.d(o,i,function(e){return n[e]}.bind(null,i));return o},t.n=function(n){var e=n&&n.__esModule?function(){return n.default}:function(){return n};return t.d(e,"a",e),e},t.o=function(n,e){return Object.prototype.hasOwnProperty.call(n,e)},t.p="",t(t.s=0)}([function(n,e,t){"use strict";function o(n){return(o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(n){return typeof n}:function(n){return n&&"function"==typeof Symbol&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n})(n)}t.r(e);var i={md5:"",ondevtoolopen:function(){i.url?window.location.href=i.url:(window.opener=null,window.open("","_self"),window.close(),window.history.back(),setTimeout((function(){window.location.href="http://localhost"}),100))},url:"",tkName:"ddtk",debugDelay:200,interval:200,disableMenu:!0,stopIntervalTime:5e3};function r(){window.addEventListener("keydown",(function(n){if(123===((n=n||window.event).keyCode||n.which)||n.shiftKey&&n.ctrlKey&&73===n.keyCode)return n.returnValue=!1,n.preventDefault(),!1}),!1),(i.disableMenu||function(){var n=navigator.userAgent,e=n.indexOf("compatible")>-1&&n.indexOf("MSIE")>-1,t=n.indexOf("Edge")>-1&&!e,o=n.indexOf("Trident")>-1&&n.indexOf("rv:11.0")>-1;return e||t||o}())&&window.addEventListener("contextmenu",(function(n){return(n=n||window.event).returnValue=!1,n.preventDefault(),!1}),!1)}var u=null,a=null,d=[];function f(){var n,e,t,o,r,f,c=!1,l=function(){c=!0},s=function(){c=!1};n=l,e=s,t=window.alert,o=window.confirm,r=window.prompt,f=function(t){return function(){n&&n(),t.apply(void 0,arguments),e&&e()}},window.alert=f(t),window.confirm=f(o),window.prompt=f(r),function(n,e){var t,o,i;void 0!==document.hidden?(t="hidden",i="visibilitychange",o="visibilityState"):void 0!==document.mozHidden?(t="mozHidden",i="mozvisibilitychange",o="mozVisibilityState"):void 0!==document.msHidden?(t="msHidden",i="msvisibilitychange",o="msVisibilityState"):void 0!==document.webkitHidden&&(t="webkitHidden",i="webkitvisibilitychange",o="webkitVisibilityState");var r=function(){document[o]===t?e():n()};document.removeEventListener(i,r,!1),document.addEventListener(i,r,!1)}(s,l),u=window.setInterval((function(){console.log(1),c||d.forEach((function(n){n()}))}),i.interval),a=setTimeout((function(){/(iphone|ipad|ipod|ios|android)/i.test(navigator.userAgent.toLowerCase())&&window.clearInterval(u)}),i.stopIntervalTime)}function c(n,e,t,o,i,r){return m((u=m(m(e,n),m(o,r)))<<(a=i)|u>>>32-a,t);var u,a}function l(n,e,t,o,i,r,u){return c(e&t|~e&o,n,e,i,r,u)}function s(n,e,t,o,i,r,u){return c(e&o|t&~o,n,e,i,r,u)}function v(n,e,t,o,i,r,u){return c(e^t^o,n,e,i,r,u)}function p(n,e,t,o,i,r,u){return c(t^(e|~o),n,e,i,r,u)}function m(n,e){var t=(65535&n)+(65535&e);return(n>>16)+(e>>16)+(t>>16)<<16|65535&t}var b=function(n){return function(n){for(var e="0123456789abcdef",t="",o=0;o<4*n.length;o++)t+=e.charAt(n[o>>2]>>o%4*8+4&15)+e.charAt(n[o>>2]>>o%4*8&15);return t}(function(n,e){n[e>>5]|=128<>>9<<4)]=e;for(var t=1732584193,o=-271733879,i=-1732584194,r=271733878,u=0;u>5]|=(255&n.charCodeAt(t/8))<0&&void 0!==arguments[0]?arguments[0]:{};for(var e in i)n[e]&&o(i[e])===o(n[e])&&(i[e]=n[e])}(n),function(){if(i.md5){var n=function(n){var e=window.location.search;if(""!==e){var t=new RegExp("(^|&)"+n+"=([^&]*)(&|$)","i"),o=e.substr(1).match(t);if(null!=o)return unescape(o[2])}return""}(i.tkName);if(b(n)===i.md5)return!0}return!1}()||(f(),r(),function(){var n=~navigator.userAgent.indexOf("Firefox"),e="";n?(e=/./).toString=function(){g()}:(e=new Image).__defineGetter__("id",(function(){g()}));t=function(){console.log(e),console.clear&&console.clear()},d.push(t);var t}())}w.md5=b,w.version="0.0.7";var y=!1;function g(){y||(y=!0,window.clearTimeout(a),i.ondevtoolopen())}!function(){var n=document.querySelector("[disable-devtool-auto]");if(n){var e={};["md5","url","tk-name","debug-delay","interval","disable-menu"].forEach((function(t){var o=n.getAttribute(t);null!==o&&("debug-delay"===t||"interval"===t?o=parseInt(o):"disable-menu"===t&&(o="false"!==o),e[function(n){if(-1===n.indexOf("-"))return n;var e=!1;return n.split("").map((function(n){return"-"===n?(e=!0,""):e?(e=!1,n.toUpperCase()):n})).join("")}(t)]=o)})),w(e)}}();e.default=w}]).default}));
\ No newline at end of file
+!function(n,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.DisableDevtool=e():n.DisableDevtool=e()}(this,(function(){return function(n){var e={};function t(o){if(e[o])return e[o].exports;var r=e[o]={i:o,l:!1,exports:{}};return n[o].call(r.exports,r,r.exports,t),r.l=!0,r.exports}return t.m=n,t.c=e,t.d=function(n,e,o){t.o(n,e)||Object.defineProperty(n,e,{enumerable:!0,get:o})},t.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})},t.t=function(n,e){if(1&e&&(n=t(n)),8&e)return n;if(4&e&&"object"==typeof n&&n&&n.__esModule)return n;var o=Object.create(null);if(t.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:n}),2&e&&"string"!=typeof n)for(var r in n)t.d(o,r,function(e){return n[e]}.bind(null,r));return o},t.n=function(n){var e=n&&n.__esModule?function(){return n.default}:function(){return n};return t.d(e,"a",e),e},t.o=function(n,e){return Object.prototype.hasOwnProperty.call(n,e)},t.p="",t(t.s=0)}([function(n,e,t){"use strict";function o(){return r("qqbrowser")}function r(n){return-1!==navigator.userAgent.toLocaleLowerCase().indexOf(n)}function i(n){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(n){return typeof n}:function(n){return n&&"function"==typeof Symbol&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n})(n)}t.r(e);var u={md5:"",ondevtoolopen:function(){u.url?window.location.href=u.url:(window.opener=null,window.open("","_self"),window.close(),window.history.back(),setTimeout((function(){window.location.href="https://tackchen.gitee.io/404.html?h=".concat(encodeURIComponent(location.host))}),100))},url:"",tkName:"ddtk",interval:200,disableMenu:!0,stopIntervalTime:5e3};var a=null,c=null,f=[];function l(){var n,e,t,o,r,i,l=!1,d=function(){l=!0},s=function(){l=!1};n=d,e=s,t=window.alert,o=window.confirm,r=window.prompt,i=function(t){return function(){n&&n(),t.apply(void 0,arguments),e&&e()}},window.alert=i(t),window.confirm=i(o),window.prompt=i(r),function(n,e){var t,o,r;void 0!==document.hidden?(t="hidden",r="visibilitychange",o="visibilityState"):void 0!==document.mozHidden?(t="mozHidden",r="mozvisibilitychange",o="mozVisibilityState"):void 0!==document.msHidden?(t="msHidden",r="msvisibilitychange",o="msVisibilityState"):void 0!==document.webkitHidden&&(t="webkitHidden",r="webkitvisibilitychange",o="webkitVisibilityState");var i=function(){document[o]===t?e():n()};document.removeEventListener(r,i,!1),document.addEventListener(r,i,!1)}(s,d),a=window.setInterval((function(){l||f.forEach((function(n){n()}))}),u.interval),c=setTimeout((function(){/(iphone|ipad|ipod|ios|android)/i.test(navigator.userAgent.toLowerCase())&&window.clearInterval(a)}),u.stopIntervalTime)}function d(n,e,t,o,r,i){return w((u=w(w(e,n),w(o,i)))<<(a=r)|u>>>32-a,t);var u,a}function s(n,e,t,o,r,i,u){return d(e&t|~e&o,n,e,r,i,u)}function v(n,e,t,o,r,i,u){return d(e&o|t&~o,n,e,r,i,u)}function m(n,e,t,o,r,i,u){return d(e^t^o,n,e,r,i,u)}function p(n,e,t,o,r,i,u){return d(t^(e|~o),n,e,r,i,u)}function w(n,e){var t=(65535&n)+(65535&e);return(n>>16)+(e>>16)+(t>>16)<<16|65535&t}var b=function(n){return function(n){for(var e="0123456789abcdef",t="",o=0;o<4*n.length;o++)t+=e.charAt(n[o>>2]>>o%4*8+4&15)+e.charAt(n[o>>2]>>o%4*8&15);return t}(function(n,e){n[e>>5]|=128<>>9<<4)]=e;for(var t=1732584193,o=-271733879,r=-1732584194,i=271733878,u=0;u>5]|=(255&n.charCodeAt(t/8))<0&&void 0!==arguments[0]?arguments[0]:{};for(var e in u)n[e]&&i(u[e])===i(n[e])&&(u[e]=n[e])}(n),function(){if(u.md5){var n=function(n){var e=window.location.search;if(""!==e){var t=new RegExp("(^|&)"+n+"=([^&]*)(&|$)","i"),o=e.substr(1).match(t);if(null!=o)return unescape(o[2])}return""}(u.tkName);if(b(n)===u.md5)return!0}return!1}()||(l(),window.addEventListener("keydown",(function(n){if(123===((n=n||window.event).keyCode||n.which)||n.shiftKey&&n.ctrlKey&&73===n.keyCode)return n.returnValue=!1,n.preventDefault(),!1}),!1),u.disableMenu&&window.addEventListener("contextmenu",(function(n){return(n=n||window.event).returnValue=!1,n.preventDefault(),!1}),!1),function(){var n=o(),e=r("firefox"),t="";if(n){var i=0;t=/./,console.log(t),t.toString=function(){var n=g(),e=n.time,t=n.next;return i&&e-i<100?t():i=e,""}}else e?(t=/./,console.log(t),t.toString=function(){return g().next(),""}):(t=new Image).__defineGetter__("id",(function(){g().next()}));u=function(){console.log(t),console.clear()},f.push(u);var u}())}y.md5=b,y.version="0.1.0";var h=!1;function g(){var n=(new Date).getTime();if(console.log("You ar not allow to use DEVTOOL!",n),!o()){if(h)return{time:n,next:function(){}};h=!0}return{time:n,next:function(){window.clearTimeout(c),u.ondevtoolopen()}}}!function(){var n=document.querySelector("[disable-devtool-auto]");if(n){var e={};["md5","url","tk-name","interval","disable-menu"].forEach((function(t){var o=n.getAttribute(t);null!==o&&("interval"===t?o=parseInt(o):"disable-menu"===t&&(o="false"!==o),e[function(n){if(-1===n.indexOf("-"))return n;var e=!1;return n.split("").map((function(n){return"-"===n?(e=!0,""):e?(e=!1,n.toUpperCase()):n})).join("")}(t)]=o)})),y(e)}}();e.default=y}]).default}));
\ No newline at end of file
diff --git a/npm/index.d.ts b/npm/index.d.ts
index ae6be71..1b4bdbb 100644
--- a/npm/index.d.ts
+++ b/npm/index.d.ts
@@ -3,9 +3,8 @@ declare interface optionStatic {
url?: string; // 关闭页面失败时的跳转页面,默认值为localhost
tkName?: string; // 绕过禁用时的url参数名称,默认为 ddtk
ondevtoolopen?(): void; // 开发者面板打开的回调,启用时url参数无效
- debugDelay?: number; // debug模式时的延迟 默认200ms
interval?: number; // 定时器的时间间隔 默认200ms
- disableMenu?: boolean; // 是否禁用右键菜单 默认为true ie下无效
+ disableMenu?: boolean; // 是否禁用右键菜单 默认为true
stopIntervalTime?: number; // 在移动端时取消监视的等待时长
}
declare interface DDTStatic {
diff --git a/npm/package.json b/npm/package.json
index 0b2bf22..71f3532 100644
--- a/npm/package.json
+++ b/npm/package.json
@@ -1,14 +1,9 @@
{
"name": "disable-devtool",
- "version": "0.0.8",
+ "version": "0.1.0",
"description": "Disable web developer tools from the f12 button, right-click and browser ",
"main": "disable-devtool.min.js",
"scripts": {
- "dev": "webpack-dev-server --open --config webpack-config/dev.js",
- "start": "npm run dev",
- "build": "webpack --config webpack-config/build.js",
- "publish": "npm publish npm",
- "lint": "eslint src --ext js"
},
"unpkg": "disable-devtool.min.js",
"jsdelivr": "disable-devtool.min.js",
@@ -18,7 +13,9 @@
"url": "https://github.com/theajack/disable-devtool"
},
"keywords": [
- "disable-devtool"
+ "disable-devtool",
+ "禁用F12",
+ "禁用开发者工具"
],
"author": "theajack",
"license": "MIT",
diff --git a/package.json b/package.json
index 7ec95a4..34693f4 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "disable-devtool",
- "version": "0.0.8",
+ "version": "0.1.0",
"description": "Disable web developer tools from the f12 button, right-click and browser ",
"main": "disable-devtool.min.js",
"unpkg": "disable-devtool.min.js",
@@ -23,7 +23,9 @@
"url": "https://github.com/theajack/disable-devtool"
},
"keywords": [
- "ebuild-cli"
+ "disable-devtool",
+ "禁用F12",
+ "禁用开发者工具"
],
"license": "MIT",
"devDependencies": {
diff --git a/public/main.js b/public/main.js
index a09fa44..f8315fe 100644
--- a/public/main.js
+++ b/public/main.js
@@ -1,5 +1,7 @@
-// import disableDevtool from '../src';
-import disableDevtool from '../npm';
+import disableDevtool from '../src';
+// import disableDevtool from '../npm';
+
+// debugger;
disableDevtool({
md5: 'd4de605ccb923b7e876b3218a1474653',
diff --git a/src/config.js b/src/config.js
index d3f7eff..0be1696 100644
--- a/src/config.js
+++ b/src/config.js
@@ -5,7 +5,6 @@ export let config = {
ondevtoolopen: closeWindow, // ondevtoolopen 优先级高于 url
url: '',
tkName: 'ddtk',
- debugDelay: 200,
interval: 200,
disableMenu: true, // 该参数ie下无效,ie 右键菜单会阻塞线程影响debug延迟计算 禁用右键菜单
stopIntervalTime: 5000, // 在移动端时取消监视的等待时长
diff --git a/src/index.d.ts b/src/index.d.ts
index ae6be71..1b4bdbb 100644
--- a/src/index.d.ts
+++ b/src/index.d.ts
@@ -3,9 +3,8 @@ declare interface optionStatic {
url?: string; // 关闭页面失败时的跳转页面,默认值为localhost
tkName?: string; // 绕过禁用时的url参数名称,默认为 ddtk
ondevtoolopen?(): void; // 开发者面板打开的回调,启用时url参数无效
- debugDelay?: number; // debug模式时的延迟 默认200ms
interval?: number; // 定时器的时间间隔 默认200ms
- disableMenu?: boolean; // 是否禁用右键菜单 默认为true ie下无效
+ disableMenu?: boolean; // 是否禁用右键菜单 默认为true
stopIntervalTime?: number; // 在移动端时取消监视的等待时长
}
declare interface DDTStatic {
diff --git a/src/interval.js b/src/interval.js
index 0e9fb7f..e2b2913 100644
--- a/src/interval.js
+++ b/src/interval.js
@@ -12,7 +12,6 @@ export function initInterval () {
onPageShowHide(goon, pause); // 防止切后台触发了debug延迟计算
interval = window.setInterval(() => {
- console.log(1);
if (_pause) return;
calls.forEach(fn => {fn();});
}, config.interval);
diff --git a/src/key-menu.js b/src/key-menu.js
index 7f010e5..0d72d57 100644
--- a/src/key-menu.js
+++ b/src/key-menu.js
@@ -1,5 +1,4 @@
import {config} from './config';
-import {isIE} from './util';
export function disableKeyAndMenu () {
window.addEventListener('keydown', (e) => {
@@ -12,7 +11,7 @@ export function disableKeyAndMenu () {
return false;
}
}, false);
- if (config.disableMenu || isIE()) { // ie 右键菜单会阻塞线程影响debug延迟计算 禁用右键菜单
+ if (config.disableMenu) {
window.addEventListener('contextmenu', (e) => {
e = e || window.event;
e.returnValue = false;
diff --git a/src/main.js b/src/main.js
index 919b079..418d493 100644
--- a/src/main.js
+++ b/src/main.js
@@ -1,6 +1,6 @@
import {disableKeyAndMenu} from './key-menu';
import {initInterval, registInterval, clearTimeout} from './interval';
-import {formatName, getUrlParam} from './util';
+import {formatName, getUrlParam, isFirefox, isQQBrowser} from './util';
import {mergeConfig, config} from './config';
import md5 from './md5';
import version from './version';
@@ -11,7 +11,6 @@ export function disableDevtool (opts) {
initInterval();
disableKeyAndMenu();
initDevTool();
- // initDebugger();
}
disableDevtool.md5 = md5;
@@ -19,10 +18,16 @@ disableDevtool.version = version;
let hasOpened = false;
export function onDevToolOpen () {
- if (hasOpened) {return;}
- hasOpened = true;
- clearTimeout();
- config.ondevtoolopen();
+ let time = new Date().getTime();
+ console.log('You ar not allow to use DEVTOOL!', time);
+ if (!isQQBrowser()) {
+ if (hasOpened) {return {time, next () {}};}
+ hasOpened = true;
+ }
+ return {time, next () {
+ clearTimeout();
+ config.ondevtoolopen();
+ }};
}
function checkTk () {
@@ -35,42 +40,39 @@ function checkTk () {
return false;
}
-// let disableDebug = false; // 当 initDevTool 方式生效时,去除debug断点
-// 去除debug的逻辑
-// function initDebugger () {
-// let debug = new Function('debugger');
-// registInterval(() => {
-// if (disableDebug) {
-// return;
-// }
-// var last = getNowTime();
-// // debug();
-// // interval 时间是 config.interval,设置config.debugDelay是为了给一个执行的时间
-// if (getNowTime() - last > config.interval + config.debugDelay) {
-// onDevToolOpen();
-// }
-// });
-// }
-
function initDevTool () {
- const isFF = ~navigator.userAgent.indexOf('Firefox');
+ const isQQ = isQQBrowser();
+ const isFF = isFirefox();
let toTest = '';
- if (isFF) {
+ if (isQQ) {
+ let lastTime = 0;
toTest = /./;
+ console.log(toTest);
toTest.toString = function () {
- // disableDebug = true;
- onDevToolOpen();
+ let {time, next} = onDevToolOpen();
+ if (lastTime && time - lastTime < 100) {
+ next();
+ } else {
+ lastTime = time;
+ }
+ return '';
+ };
+ } else if (isFF) {
+ toTest = /./;
+ console.log(toTest);
+ toTest.toString = function () {
+ onDevToolOpen().next();
+ return '';
};
} else {
toTest = new Image();
toTest.__defineGetter__('id', function () {
- // disableDebug = true;
- onDevToolOpen();
+ onDevToolOpen().next();
});
}
registInterval(() => {
console.log(toTest);
- console.clear && console.clear();
+ console.clear();
});
}
@@ -80,10 +82,10 @@ function checkScriptUse () {
return;
}
let json = {};
- ['md5', 'url', 'tk-name', 'debug-delay', 'interval', 'disable-menu'].forEach(name => {
+ ['md5', 'url', 'tk-name', 'interval', 'disable-menu'].forEach(name => {
let value = dom.getAttribute(name);
if (value !== null) {
- if (name === 'debug-delay' || name === 'interval') {
+ if (name === 'interval') {
value = parseInt(value);
} else if (name === 'disable-menu') {
value = value === 'false' ? false : true;
diff --git a/src/util.js b/src/util.js
index 1e8f1bb..3529156 100644
--- a/src/util.js
+++ b/src/util.js
@@ -14,7 +14,7 @@ export function closeWindow () {
window.close();
window.history.back();
setTimeout(() => {
- window.location.href = 'http://localhost';
+ window.location.href = `https://tackchen.gitee.io/404.html?h=${encodeURIComponent(location.host)}`;
}, 100);
}
// 否则执行跳转到 url
@@ -129,4 +129,16 @@ export function isIE () {
// } else {
// return -1;// 不是ie浏览器
// }
+}
+
+export function isQQBrowser () {
+ return hasUaName('qqbrowser');
+}
+
+export function isFirefox () {
+ return hasUaName('firefox');
+}
+
+function hasUaName (name) {
+ return navigator.userAgent.toLocaleLowerCase().indexOf(name) !== -1;
}
\ No newline at end of file
diff --git a/src/version.js b/src/version.js
index 3bc7502..cbec741 100644
--- a/src/version.js
+++ b/src/version.js
@@ -1 +1 @@
-export default '0.0.7';
\ No newline at end of file
+export default '0.1.0';
\ No newline at end of file