diff --git a/helper/copy-to-npm.js b/helper/copy-to-npm.js index 62dff33..cbb6d06 100644 --- a/helper/copy-to-npm.js +++ b/helper/copy-to-npm.js @@ -21,7 +21,7 @@ function copyPkg () { } function copyFiles () { - gulp.src(['README.md', 'README.cn.md', 'LICENSE', 'src/index.d.ts'], { + gulp.src(['README.md', 'LICENSE', 'src/index.d.ts'], { allowEmpty: true }) .pipe(gulp.dest('npm')); diff --git a/helper/testcdn.html b/helper/testcdn.html index e5001e9..5c09ca6 100644 --- a/helper/testcdn.html +++ b/helper/testcdn.html @@ -11,5 +11,15 @@ md5='d4de605ccb923b7e876b3218a1474653' tk-name='tk' src="../npm/disable-devtool.min.js"> + \ No newline at end of file diff --git a/helper/version.en.md b/helper/version.en.md index 8edfac8..45b8002 100644 --- a/helper/version.en.md +++ b/helper/version.en.md @@ -70,4 +70,7 @@ 1. Fix the bug of accidental injury in IFrame ## 0.1.10 -3. Fix the problem that sizeDetector is accidentally injured in browser zoom mode \ No newline at end of file +1. Fix the problem that sizeDetector is accidentally injured in browser zoom mode + +## 0.1.11 +1. Fix the accidental injury caused by the third-party hack console.log method \ No newline at end of file diff --git a/helper/version.md b/helper/version.md index 175284c..8dcebf7 100644 --- a/helper/version.md +++ b/helper/version.md @@ -70,4 +70,7 @@ 1. 修复IFrame中误伤的bug ## 0.1.10 -1. 修复sizeDetector在浏览器缩放模式下误伤的问题 \ No newline at end of file +1. 修复sizeDetector在浏览器缩放模式下误伤的问题 + +## 0.1.11 +1. 修复第三方 hack console.log方法 导致的误伤 \ No newline at end of file diff --git a/index.html b/index.html index d471c83..aa4d5fe 100644 --- a/index.html +++ b/index.html @@ -182,7 +182,7 @@ declare type DETECTOR_TYPE = -1 | 0 | 1 | 2 | 3;

-``` - -或者通过版本引用: - -```html - - - - -``` - -## 2.功能 - -disable-devtool 可以禁用所有一切可以进入开发者工具的方法,防止通过开发者工具进行的 ‘代码搬运’ - -该库有以下特性: - -1. 支持可配置是否禁用右键菜单 -2. 禁用 f12 和 ctrl+shift+i 快捷键 -3. 支持识别从浏览器菜单栏打开开发者工具并关闭当前页面 -4. 开发者可以绕过禁用 (url参数使用tk配合md5加密) -5. 多种监测模式,支持几乎所有浏览器(IE,360,qq浏览器,FireFox,Chrome,Edge...) -6. 高度可配置 -7. 使用极简、体积小巧 (仅7kb) -8. 支持npm引用和script标签引用(属性配置) -9. 识别真移动端与浏览器开发者工具设置插件伪造的移动端,为移动端节省性能 - -## 3. 使用 - -### 3.1 npm使用时的配置参数 - -安装 disable-devtool - -``` -npm i disable-devtool -``` - -```js -import disableDevtool from 'disable-devtool'; - -disableDevtool(options); -``` - -options中的参数与说明如下: - -```ts -declare interface optionStatic { - md5?: string; // 绕过禁用的md5值,详情见3.2,默认不启用绕过禁用 - url?: string; // 关闭页面失败时的跳转页面,默认值为localhost - tkName?: string; // 绕过禁用时的url参数名称,默认为 ddtk - ondevtoolopen?(type: DetectorType): void; // 开发者面板打开的回调,启用时url参数无效,type 为监测模式,详见3.5 - interval?: number; // 定时器的时间间隔 默认200ms - disableMenu?: boolean; // 是否禁用右键菜单 默认为true - stopIntervalTime?: number; // 在移动端时取消监视的等待时长 - clearIntervalWhenDevOpenTrigger?: boolean; // 是否在触发之后停止监控 默认为false - detactors?: Array; // 启用的检测器 检测器详情见 3.5 默认为全部,建议使用全部 -} - -declare type DETECTOR_TYPE = -1 | 0 | 1 | 2 | 3 | 4; // 检测器详情见 3.5 -``` - -### 3.2 md5 与 tk 绕过禁用 - -该库中使用 key 与 md5 配合的方式使得开发者可以在线上绕过禁用。 - -流程如下: - -先指定一个 key a(该值不要记录在代码中),使用 md5 加密得到一个值 b,将b作为 md5 参数传入,开发者在访问 url 的时候只需要带上url参数 ddtk=a,便可以绕过禁用。 - -disableDevtool对象暴露了 md5 方法,可供开发者加密时使用: - -```js -disableDevtool.md5('xxx'); -``` - -### 3.3 script使用属性配置 - -```html - -``` - -注: - -1. 如希望自动禁用,属性配置时必须要带上 `disable-devtool-auto` 属性 -2. 属性配置都是可选的,字段与3.1中一致,区别是将驼峰形式改成横线分割 -3. 该script标签建议放在body最底部 -4. detectors 需要使用空格分割,如 detectors='1 2 3' - -### 3.4 script不使用属性配置 - -```html - - -``` - -### 3.5 监测模式 - -Disable-Devtool 有五种监测模式, DisableDevtool.DETECTOR_TYPE 为所有的监测模式枚举 - -```js -const DETECTOR_TYPE = { - UNKONW: -1, - REG_TO_STRING: 0, // 根据正则检测 - DEFINE_ID: 1, // 根据dom id检测 - SIZE: 2, // 根据窗口尺寸检测 - DATE_TO_STRING: 3, // 根据Date.toString 检测 - FUNC_TO_STRING: 4, // 根据Function.toString 检测 -} -``` - -ondevtoolopen 事件的回调参数就是被触发的监测模式 \ No newline at end of file diff --git a/npm/disable-devtool.min.js b/npm/disable-devtool.min.js index 1411cf6..20552e7 100644 --- a/npm/disable-devtool.min.js +++ b/npm/disable-devtool.min.js @@ -1 +1 @@ -!function(e,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports.DisableDevtool=n():e.DisableDevtool=n()}(this,(function(){return function(e){var n={};function t(o){if(n[o])return n[o].exports;var i=n[o]={i:o,l:!1,exports:{}};return e[o].call(i.exports,i,i.exports,t),i.l=!0,i.exports}return t.m=e,t.c=n,t.d=function(e,n,o){t.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:o})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,n){if(1&n&&(e=t(e)),8&n)return e;if(4&n&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(t.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&n&&"string"!=typeof e)for(var i in e)t.d(o,i,function(n){return e[n]}.bind(null,i));return o},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},t.p="",t(t.s=0)}([function(e,n,t){"use strict";t.r(n);var o=null,i=null,r=[],u=0;function c(){var e,n,t,c,a,f,d=!1,s=function(){d=!0},w=function(){d=!1};e=s,n=w,t=window.alert,c=window.confirm,a=window.prompt,f=function(t){return function(){e&&e(),t.apply(void 0,arguments),n&&n()}},window.alert=f(t),window.confirm=f(c),window.prompt=f(a),function(e,n){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?n():e()};document.removeEventListener(i,r,!1),document.addEventListener(i,r,!1)}(w,s),o=window.setInterval((function(){d||(r.forEach((function(e){e(u++)})),console.clear())}),v.interval),i=setTimeout((function(){/(iphone|ipad|ipod|ios|android)/i.test(navigator.userAgent.toLowerCase())&&l()}),v.stopIntervalTime)}function a(e){r.push(e)}function l(){window.clearInterval(o)}function f(){window.clearTimeout(i)}function d(e){return-1!==navigator.userAgent.toLocaleLowerCase().indexOf(e)}function s(e){return(s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var v={md5:"",ondevtoolopen:function(){if(l(),v.url)window.location.href=v.url;else{try{window.opener=null,window.open("","_self"),window.close(),window.history.back()}catch(e){console.log(e)}setTimeout((function(){window.location.href="https://tackchen.gitee.io/404.html?h=".concat(encodeURIComponent(location.host))}),500)}},url:"",tkName:"ddtk",interval:200,disableMenu:!0,stopIntervalTime:5e3,clearIntervalWhenDevOpenTrigger:!1,detectors:"all"},w=["detectors"];function m(){var e="shiftKey",n="ctrlKey";d("macintosh")&&(e="metaKey",n="altKey"),window.addEventListener("keydown",(function(t){if(123===((t=t||window.event).keyCode||t.which)||t[e]&&t[n]&&73===t.keyCode)return t.returnValue=!1,t.preventDefault(),!1}),!0),v.disableMenu&&window.addEventListener("contextmenu",(function(e){return(e=e||window.event).returnValue=!1,e.preventDefault(),!1}),!0)}function p(e,n,t,o,i,r){return T((u=T(T(n,e),T(o,r)))<<(c=i)|u>>>32-c,t);var u,c}function y(e,n,t,o,i,r,u){return p(n&t|~n&o,e,n,i,r,u)}function b(e,n,t,o,i,r,u){return p(n&o|t&~o,e,n,i,r,u)}function h(e,n,t,o,i,r,u){return p(n^t^o,e,n,i,r,u)}function g(e,n,t,o,i,r,u){return p(t^(n|~o),e,n,i,r,u)}function T(e,n){var t=(65535&e)+(65535&n);return(e>>16)+(n>>16)+(t>>16)<<16|65535&t}var _,I=function(e){return function(e){for(var n="0123456789abcdef",t="",o=0;o<4*e.length;o++)t+=n.charAt(e[o>>2]>>o%4*8+4&15)+n.charAt(e[o>>2]>>o%4*8&15);return t}(function(e,n){e[n>>5]|=128<>>9<<4)]=n;for(var t=1732584193,o=-271733879,i=-1732584194,r=271733878,u=0;u>5]|=(255&e.charCodeAt(t/8))<200,t=window.outerHeight-window.innerHeight*e>300;return!n&&!t||(R(D.SIZE),!1)}function S(e){return null!=e}function O(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}var D={UNKONW:-1,REG_TO_STRING:0,DEFINE_ID:1,SIZE:2,DATE_TO_STRING:3,FUNC_TO_STRING:4},N=(O(_={},D.REG_TO_STRING,(function(){var e=d("qqbrowser"),n=d("firefox");if(e||n){var t=0,o=/./;console.log(o),o.toString=function(){if(e){var o=(new Date).getTime();t&&o-t<100?R(D.REG_TO_STRING):t=o}else n&&R(D.REG_TO_STRING);return""},a((function(){console.log(o)}))}})),O(_,D.DEFINE_ID,(function(){var e=document.createElement("div");e.__defineGetter__("id",(function(){R(D.DEFINE_ID)})),Object.defineProperty(e,"id",{get:function(){R(D.DEFINE_ID)}}),a((function(){console.log(e)}))})),O(_,D.SIZE,(function(){!function(){try{return window.self!==window.top}catch(e){return!0}}()?(E(),window.addEventListener("resize",(function(){setTimeout(E,100)}),!0)):console.warn("SizeDetector is disabled in IFrame")})),O(_,D.DATE_TO_STRING,(function(){var e=0,n=new Date;n.toString=function(){return e++,""},a((function(){e=0,console.log(n),console.clear(),e>=2&&R(D.DATE_TO_STRING)}))})),O(_,D.FUNC_TO_STRING,(function(){var e=0,n=function(){};n.toString=function(){return e++,""},a((function(){e=0,console.log(n),console.clear(),e>=2&&R(D.FUNC_TO_STRING)}))})),_);function R(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:D.UNKONW;console.warn("You ar not allow to use DEVTOOL! 【type = ".concat(e,"】")),v.clearIntervalWhenDevOpenTrigger&&l(),f(),v.ondevtoolopen(e)}function x(e){!function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};for(var n in v)void 0===e[n]||s(v[n])!==s(e[n])&&!w.includes(n)||(v[n]=e[n])}(e),function(){if(v.md5){var e=function(e){var n=window.location.search;if(""!==n){var t=new RegExp("(^|&)"+e+"=([^&]*)(&|$)","i"),o=n.substr(1).match(t);if(null!=o)return unescape(o[2])}return""}(v.tkName);if(I(e)===v.md5)return!0}return!1}()||(c(),m(),("all"===v.detectors?Object.keys(N):v.detectors).forEach((function(e){N[e]&&N[e]()})))}x.md5=I,x.version="0.1.10",x.DETECTOR_TYPE=D,function(){if("undefined"!=typeof document){var e=document.querySelector("[disable-devtool-auto]");if(e){var n={};["md5","url","tk-name","interval","disable-menu","detectors"].forEach((function(t){var o=e.getAttribute(t);null!==o&&("interval"===t?o=parseInt(o):"disable-menu"===t?o="false"!==o:"detector"===t&&"all"!==o&&(o=o.split(" ")),n[function(e){if(-1===e.indexOf("-"))return e;var n=!1;return e.split("").map((function(e){return"-"===e?(n=!0,""):n?(n=!1,e.toUpperCase()):e})).join("")}(t)]=o)})),x(n)}}}();n.default=x}]).default})); \ No newline at end of file +!function(e,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports.DisableDevtool=n():e.DisableDevtool=n()}(this,(function(){return function(e){var n={};function t(o){if(n[o])return n[o].exports;var i=n[o]={i:o,l:!1,exports:{}};return e[o].call(i.exports,i,i.exports,t),i.l=!0,i.exports}return t.m=e,t.c=n,t.d=function(e,n,o){t.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:o})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,n){if(1&n&&(e=t(e)),8&n)return e;if(4&n&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(t.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&n&&"string"!=typeof e)for(var i in e)t.d(o,i,function(n){return e[n]}.bind(null,i));return o},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},t.p="",t(t.s=0)}([function(e,n,t){"use strict";t.r(n);var o=null,i=null,r=[],u=0;function c(){var e,n,t,c,a,l,d=!1,s=function(){d=!0},v=function(){d=!1};e=s,n=v,t=window.alert,c=window.confirm,a=window.prompt,l=function(t){return function(){e&&e(),t.apply(void 0,arguments),n&&n()}},window.alert=l(t),window.confirm=l(c),window.prompt=l(a),function(e,n){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?n():e()};document.removeEventListener(i,r,!1),document.addEventListener(i,r,!1)}(v,s),o=window.setInterval((function(){d||(r.forEach((function(e){e(u++)})),console.clear())}),w.interval),i=setTimeout((function(){/(iphone|ipad|ipod|ios|android)/i.test(navigator.userAgent.toLowerCase())&&f()}),w.stopIntervalTime)}function a(e){r.push(e)}function f(){window.clearInterval(o)}function l(){window.clearTimeout(i)}function d(e){return-1!==navigator.userAgent.toLocaleLowerCase().indexOf(e)}var s=console.log;function v(e){return(v="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var w={md5:"",ondevtoolopen:function(){if(f(),w.url)window.location.href=w.url;else{try{window.opener=null,window.open("","_self"),window.close(),window.history.back()}catch(e){console.log(e)}setTimeout((function(){window.location.href="https://tackchen.gitee.io/404.html?h=".concat(encodeURIComponent(location.host))}),500)}},url:"",tkName:"ddtk",interval:200,disableMenu:!0,stopIntervalTime:5e3,clearIntervalWhenDevOpenTrigger:!1,detectors:"all"},m=["detectors"];function p(){var e="shiftKey",n="ctrlKey";d("macintosh")&&(e="metaKey",n="altKey"),window.addEventListener("keydown",(function(t){if(123===((t=t||window.event).keyCode||t.which)||t[e]&&t[n]&&73===t.keyCode)return t.returnValue=!1,t.preventDefault(),!1}),!0),w.disableMenu&&window.addEventListener("contextmenu",(function(e){return(e=e||window.event).returnValue=!1,e.preventDefault(),!1}),!0)}function y(e,n,t,o,i,r){return _((u=_(_(n,e),_(o,r)))<<(c=i)|u>>>32-c,t);var u,c}function b(e,n,t,o,i,r,u){return y(n&t|~n&o,e,n,i,r,u)}function h(e,n,t,o,i,r,u){return y(n&o|t&~o,e,n,i,r,u)}function g(e,n,t,o,i,r,u){return y(n^t^o,e,n,i,r,u)}function T(e,n,t,o,i,r,u){return y(t^(n|~o),e,n,i,r,u)}function _(e,n){var t=(65535&e)+(65535&n);return(e>>16)+(n>>16)+(t>>16)<<16|65535&t}var I,E=function(e){return function(e){for(var n="0123456789abcdef",t="",o=0;o<4*e.length;o++)t+=n.charAt(e[o>>2]>>o%4*8+4&15)+n.charAt(e[o>>2]>>o%4*8&15);return t}(function(e,n){e[n>>5]|=128<>>9<<4)]=n;for(var t=1732584193,o=-271733879,i=-1732584194,r=271733878,u=0;u>5]|=(255&e.charCodeAt(t/8))<200,t=window.outerHeight-window.innerHeight*e>300;return!n&&!t||(x(N.SIZE),!1)}function O(e){return null!=e}function D(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}var N={UNKONW:-1,REG_TO_STRING:0,DEFINE_ID:1,SIZE:2,DATE_TO_STRING:3,FUNC_TO_STRING:4},R=(D(I={},N.REG_TO_STRING,(function(){var e=d("qqbrowser"),n=d("firefox");if(e||n){var t=0,o=/./;s(o),o.toString=function(){if(e){var o=(new Date).getTime();t&&o-t<100?x(N.REG_TO_STRING):t=o}else n&&x(N.REG_TO_STRING);return""},a((function(){s(o)}))}})),D(I,N.DEFINE_ID,(function(){var e=document.createElement("div");e.__defineGetter__("id",(function(){x(N.DEFINE_ID)})),Object.defineProperty(e,"id",{get:function(){x(N.DEFINE_ID)}}),a((function(){s(e)}))})),D(I,N.SIZE,(function(){!function(){try{return window.self!==window.top}catch(e){return!0}}()?(S(),window.addEventListener("resize",(function(){setTimeout(S,100)}),!0)):console.warn("SizeDetector is disabled in IFrame")})),D(I,N.DATE_TO_STRING,(function(){var e=0,n=new Date;n.toString=function(){return e++,""},a((function(){e=0,s(n),console.clear(),e>=2&&x(N.DATE_TO_STRING)}))})),D(I,N.FUNC_TO_STRING,(function(){var e=0,n=function(){};n.toString=function(){return e++,""},a((function(){e=0,s(n),console.clear(),e>=2&&x(N.FUNC_TO_STRING)}))})),I);function x(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:N.UNKONW;console.warn("You ar not allow to use DEVTOOL! 【type = ".concat(e,"】")),w.clearIntervalWhenDevOpenTrigger&&f(),l(),w.ondevtoolopen(e)}function G(e){!function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};for(var n in w)void 0===e[n]||v(w[n])!==v(e[n])&&!m.includes(n)||(w[n]=e[n])}(e),function(){if(w.md5){var e=function(e){var n=window.location.search;if(""!==n){var t=new RegExp("(^|&)"+e+"=([^&]*)(&|$)","i"),o=n.substr(1).match(t);if(null!=o)return unescape(o[2])}return""}(w.tkName);if(E(e)===w.md5)return!0}return!1}()||(c(),p(),("all"===w.detectors?Object.keys(R):w.detectors).forEach((function(e){R[e]&&R[e]()})))}G.md5=E,G.version="0.1.11",G.DETECTOR_TYPE=N,function(){if("undefined"!=typeof document){var e=document.querySelector("[disable-devtool-auto]");if(e){var n={};["md5","url","tk-name","interval","disable-menu","detectors"].forEach((function(t){var o=e.getAttribute(t);null!==o&&("interval"===t?o=parseInt(o):"disable-menu"===t?o="false"!==o:"detector"===t&&"all"!==o&&(o=o.split(" ")),n[function(e){if(-1===e.indexOf("-"))return e;var n=!1;return e.split("").map((function(e){return"-"===e?(n=!0,""):n?(n=!1,e.toUpperCase()):e})).join("")}(t)]=o)})),G(n)}}}();n.default=G}]).default})); \ No newline at end of file diff --git a/npm/package.json b/npm/package.json index f261a5c..97d2578 100644 --- a/npm/package.json +++ b/npm/package.json @@ -1,6 +1,6 @@ { "name": "disable-devtool", - "version": "0.1.10", + "version": "0.1.11", "description": "Disable web developer tools from the f12 button, right-click and browser ", "main": "disable-devtool.min.js", "unpkg": "disable-devtool.min.js", diff --git a/package.json b/package.json index 9433c03..b301683 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "disable-devtool", - "version": "0.1.10", + "version": "0.1.11", "description": "Disable web developer tools from the f12 button, right-click and browser ", "main": "disable-devtool.min.js", "unpkg": "disable-devtool.min.js", diff --git a/src/detector/date-to-string.js b/src/detector/date-to-string.js index 925bb7b..396e054 100644 --- a/src/detector/date-to-string.js +++ b/src/detector/date-to-string.js @@ -9,6 +9,7 @@ import {registInterval} from '../interval'; import {DETECTOR_TYPE, triggerOnDevOpen} from './detector'; +import {log} from '../util'; export default function detector () { let count = 0; @@ -20,7 +21,7 @@ export default function detector () { const checkIsOpen = () => { count = 0; - console.log(date); + log(date); console.clear(); if (count >= 2) { triggerOnDevOpen(DETECTOR_TYPE.DATE_TO_STRING); diff --git a/src/detector/define-id.js b/src/detector/define-id.js index 60e9321..db99ff1 100644 --- a/src/detector/define-id.js +++ b/src/detector/define-id.js @@ -7,6 +7,7 @@ */ import {DETECTOR_TYPE, triggerOnDevOpen} from './detector'; import {registInterval} from '../interval'; +import {log} from '../util'; export default function detector () { const div = document.createElement('div'); @@ -19,6 +20,6 @@ export default function detector () { }, }); registInterval(() => { - console.log(div); + log(div); }); } \ No newline at end of file diff --git a/src/detector/func-to-string.js b/src/detector/func-to-string.js index 06ab483..983b5cf 100644 --- a/src/detector/func-to-string.js +++ b/src/detector/func-to-string.js @@ -9,6 +9,7 @@ import {registInterval} from '../interval'; import {DETECTOR_TYPE, triggerOnDevOpen} from './detector'; +import {log} from '../util'; export default function detector () { let count = 0; @@ -20,7 +21,7 @@ export default function detector () { const checkIsOpen = () => { count = 0; - console.log(func); + log(func); console.clear(); if (count >= 2) { triggerOnDevOpen(DETECTOR_TYPE.FUNC_TO_STRING); diff --git a/src/detector/log-time.js b/src/detector/log-time.js index e1690ba..3dfbb15 100644 --- a/src/detector/log-time.js +++ b/src/detector/log-time.js @@ -2,17 +2,18 @@ * @Author: theajack * @Date: 2021-07-24 23:15:22 * @LastEditor: theajack - * @LastEditTime: 2021-07-26 10:42:58 + * @LastEditTime: 2021-12-09 08:00:47 * @Description: Coding something */ // import {DETECTOR_TYPE, triggerOnDevOpen} from './detector'; // import {registInterval} from '../interval'; +// import {log} from '../util'; // function logTime () { // const d = new Date(); // for (let i = 0; i < 2000; i++) { -// console.log(1); +// log(1); // } // console.clear(); // if (new Date() - d > 100) { diff --git a/src/detector/reg-to-string.js b/src/detector/reg-to-string.js index 95c0dc1..34c27e4 100644 --- a/src/detector/reg-to-string.js +++ b/src/detector/reg-to-string.js @@ -2,12 +2,12 @@ * @Author: theajack * @Date: 2021-07-24 23:15:01 * @LastEditor: theajack - * @LastEditTime: 2021-11-15 22:26:29 + * @LastEditTime: 2021-12-09 07:58:29 * @Description: Coding something */ import {registInterval} from '../interval'; -import {isFirefox, isQQBrowser} from '../util'; +import {isFirefox, isQQBrowser, log} from '../util'; import {DETECTOR_TYPE, triggerOnDevOpen} from './detector'; // 这个方法在chrome 中无论是否打开都会触发 @@ -17,7 +17,7 @@ export default function detector () { if (!isQQ && !isFF) return; let lastTime = 0; const reg = /./; - console.log(reg); + log(reg); reg.toString = function () { if (isQQ) { // ! qq浏览器在控制台没有打开的时候也会触发 打开的时候会连续触发两次 使用这个来判断 const time = new Date().getTime(); @@ -33,6 +33,6 @@ export default function detector () { }; registInterval(() => { - console.log(reg); + log(reg); }); } \ No newline at end of file diff --git a/src/util.js b/src/util.js index a7013b3..0368408 100644 --- a/src/util.js +++ b/src/util.js @@ -129,4 +129,6 @@ export function isInIframe () { } catch (e) { return true; } -} \ No newline at end of file +} + +export const log = console.log; \ No newline at end of file diff --git a/src/version.js b/src/version.js index b290a56..9673d60 100644 --- a/src/version.js +++ b/src/version.js @@ -1 +1 @@ -export default '0.1.10'; \ No newline at end of file +export default '0.1.11'; \ No newline at end of file