feat: 0.0.7 去除debug模式

This commit is contained in:
tackchen 2021-01-23 09:34:37 +08:00
parent 77ab9ba830
commit af37b42d6d
6 changed files with 36 additions and 31 deletions

View File

@ -76,14 +76,14 @@ disableDevtool();</code>
<h3>1.2 script attribute configuration</h3> <h3>1.2 script attribute configuration</h3>
<p><code>&lt;script id=&#39;disable-devtool&#39; src=&#39;https://cdn.jsdelivr.net/npm/disable-devtool/disable-devtool.min.js&#39;&gt;&lt;/script&gt;</code></p> <p><code>&lt;script disable-devtool-auto src=&#39;https://cdn.jsdelivr.net/npm/disable-devtool/disable-devtool.min.js&#39;&gt;&lt;/script&gt;</code></p>
<p>Or use cdn with version:</p> <p>Or use cdn with version:</p>
<p><code>&lt;!--Use a specific version--> <p><code>&lt;!--Use a specific version-->
&lt;script id='disable-devtool' src='https://cdn.jsdelivr.net/npm/disable-devtool@x.x.x/disable-devtool.min.js'>&lt;/script> &lt;script disable-devtool-auto src='https://cdn.jsdelivr.net/npm/disable-devtool@x.x.x/disable-devtool.min.js'>&lt;/script>
&lt;!--Use latest version--> &lt;!--Use latest version-->
&lt;script id='disable-devtool' src='https://cdn.jsdelivr.net/npm/disable-devtool@latest/disable-devtool.min.js'>&lt;/script></code></p> &lt;script disable-devtool-auto src='https://cdn.jsdelivr.net/npm/disable-devtool@latest/disable-devtool.min.js'>&lt;/script></code></p>
<h2>2. Function</h2> <h2>2. Function</h2>
@ -151,7 +151,7 @@ disableDevtool(options);</code></p>
<h3>3.2 script uses attribute configuration</h3> <h3>3.2 script uses attribute configuration</h3>
<p><code>&lt;script <p><code>&lt;script
id=&#39;disable-devtool&#39; disable-devtool-auto
src=&#39;https://cdn.jsdelivr.net/npm/disable-devtool/disable-devtool.min.js&#39; src=&#39;https://cdn.jsdelivr.net/npm/disable-devtool/disable-devtool.min.js&#39;
md5=&#39;xxx&#39; md5=&#39;xxx&#39;
url=&#39;xxx&#39; url=&#39;xxx&#39;
@ -163,7 +163,7 @@ disableDevtool(options);</code></p>
</blockquote> </blockquote>
<p>Note:<br> <p>Note:<br>
1. You must bring the id=&#39;disable-devtool&#39;` attribute when configuring attributes<br> 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 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> 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</p>
@ -176,8 +176,13 @@ disableDevtool(options);</code></p>
// The parameters are the same as in 3.1 // The parameters are the same as in 3.1
}) })
&lt;/script&gt;</code></p> &lt;/script&gt;</code></p>
<script id='disable-devtool' md5='1aabac6d068eef6a7bad3fdf50a05cc8' src='https://cdn.jsdelivr.net/npm/disable-devtool@latest/disable-devtool.min.js'></script> <script
<!-- <script id='disable-devtool' md5='1aabac6d068eef6a7bad3fdf50a05cc8' src='./npm/disable-devtool.min.js'></script> --> disable-devtool-auto
md5='1aabac6d068eef6a7bad3fdf50a05cc8'
src='https://cdn.jsdelivr.net/npm/disable-devtool@latest/disable-devtool.min.js'
url='https://github.com/theajack/disable-devtool'
></script>
<!-- <script disable-devtool-auto md5='1aabac6d068eef6a7bad3fdf50a05cc8' src='./npm/disable-devtool.min.js'></script> -->
<script> <script>
function setText(text){ function setText(text){
document.getElementById('md5_value').innerText = text; document.getElementById('md5_value').innerText = text;

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
{ {
"name": "disable-devtool", "name": "disable-devtool",
"version": "0.0.6", "version": "0.0.7",
"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",
"scripts": { "scripts": {

View File

@ -1,6 +1,6 @@
{ {
"name": "disable-devtool", "name": "disable-devtool",
"version": "0.0.6", "version": "0.0.7",
"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",

View File

@ -1,6 +1,6 @@
import {disableKeyAndMenu} from './key-menu'; import {disableKeyAndMenu} from './key-menu';
import {initInterval, registInterval, clearTimeout} from './interval'; import {initInterval, registInterval, clearTimeout} from './interval';
import {formatName, getNowTime, getUrlParam} from './util'; import {formatName, getUrlParam} from './util';
import {mergeConfig, config} from './config'; import {mergeConfig, config} from './config';
import md5 from './md5'; import md5 from './md5';
import version from './version'; import version from './version';
@ -11,7 +11,7 @@ export function disableDevtool (opts) {
initInterval(); initInterval();
disableKeyAndMenu(); disableKeyAndMenu();
initDevTool(); initDevTool();
initDebugger(); // initDebugger();
} }
disableDevtool.md5 = md5; disableDevtool.md5 = md5;
@ -35,22 +35,22 @@ function checkTk () {
return false; return false;
} }
let disableDebug = false; // 当 initDevTool 方式生效时去除debug断点 // let disableDebug = false; // 当 initDevTool 方式生效时去除debug断点
// 去除debug的逻辑
function initDebugger () { // function initDebugger () {
let debug = new Function('debugger'); // let debug = new Function('debugger');
registInterval(() => { // registInterval(() => {
if (disableDebug) { // if (disableDebug) {
return; // return;
} // }
var last = getNowTime(); // var last = getNowTime();
debug(); // // debug();
// interval 时间是 config.interval设置config.debugDelay是为了给一个执行的时间 // // interval 时间是 config.interval设置config.debugDelay是为了给一个执行的时间
if (getNowTime() - last > config.interval + config.debugDelay) { // if (getNowTime() - last > config.interval + config.debugDelay) {
onDevToolOpen(); // onDevToolOpen();
} // }
}); // });
} // }
function initDevTool () { function initDevTool () {
const isFF = ~navigator.userAgent.indexOf('Firefox'); const isFF = ~navigator.userAgent.indexOf('Firefox');
@ -58,13 +58,13 @@ function initDevTool () {
if (isFF) { if (isFF) {
toTest = /./; toTest = /./;
toTest.toString = function () { toTest.toString = function () {
disableDebug = true; // disableDebug = true;
onDevToolOpen(); onDevToolOpen();
}; };
} else { } else {
toTest = new Image(); toTest = new Image();
toTest.__defineGetter__('id', function () { toTest.__defineGetter__('id', function () {
disableDebug = true; // disableDebug = true;
onDevToolOpen(); onDevToolOpen();
}); });
} }

View File

@ -1 +1 @@
export default '0.0.6'; export default '0.0.7';