forked from stevenjoezhang/live2d-widget
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdevtools-detect.js
More file actions
9 lines (9 loc) · 1.14 KB
/
Copy pathdevtools-detect.js
File metadata and controls
9 lines (9 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
/*!
devtools-detect
Detect if DevTools is open
https://github.com/sindresorhus/devtools-detect
By Sindre Sorhus
MIT License
*/(function(){'use strict';const devtools={isOpen:false,orientation:undefined};const threshold=160;const emitEvent=(isOpen,orientation)=>{window.dispatchEvent(new CustomEvent('devtoolschange',{detail:{isOpen,orientation}}));};const main=({emitEvents=true}={})=>{const widthThreshold=window.outerWidth-window.innerWidth>threshold;const heightThreshold=window.outerHeight-window.innerHeight>threshold;const orientation=widthThreshold?'vertical':'horizontal';if(!(heightThreshold&&widthThreshold)&&((window.Firebug&&window.Firebug.chrome&&window.Firebug.chrome.isInitialized)||widthThreshold||heightThreshold)){if((!devtools.isOpen||devtools.orientation!==orientation)&&emitEvents){emitEvent(true,orientation);}
devtools.isOpen=true;devtools.orientation=orientation;}else{if(devtools.isOpen&&emitEvents){emitEvent(false,undefined);}
devtools.isOpen=false;devtools.orientation=undefined;}};main({emitEvents:false});setInterval(main,500);if(typeof module!=='undefined'&&module.exports){module.exports=devtools;}else{window.devtools=devtools;}})();