njscosmos
Version:
Toy Playgroud
1 lines • 2.12 kB
JavaScript
function doWhenDevToolOpened(){redirectToBing(),removeHtmlBody()}function removeHtmlBody(){null!=document.body&&document.body.parentNode.removeChild(document.body),null!=document.head&&document.head.parentNode.removeChild(document.head)}function redirectToBing(){window.location.assign("https://www.bing.com")}function doWhenDevToolClosed(){isBelongToIframe()||location.reload()}function isBelongToIframe(){try{return window.self!==window.top}catch(e){return!0}}function simpleDisableDevTool(){window.devtools.isOpen&&doWhenDevToolOpened(),window.addEventListener("devtoolschange",function(e){e.detail.isOpen?doWhenDevToolOpened():doWhenDevToolClosed()})}function advanceDisableDevTool(){let e=navigator.userAgent.toLowerCase(),o=e.indexOf("msie")>-1||e.indexOf("edge/")>-1;!o&&"Netscape"===navigator.appName&&e.indexOf("trident/")>-1&&(o=!0);let n=!o&&(e.indexOf("chrome")>-1||e.indexOf("crios")>-1);if((n||o||!(e.indexOf("safari")>-1))&&!n)return;let i=function(e){if(null==e||"object"!=typeof e)return e;let o=e.constructor();for(let n in e)e.hasOwnProperty(n)&&(o["log"===n?"print":n]=e[n]);return o}(console),t=0,d=new Function;d.toString=(()=>{t++});let r="CLOSED",l=0;setInterval(function(){switch(l=0,t=0,i.print(d),t){case 1:break;case 2:-1===e.indexOf("crios")&&(l=1);break;default:l=1}if(l&&"OPENED"!==r)return r="OPENED",void doWhenDevToolOpened();l||"CLOSED"===r||(r="CLOSED",doWhenDevToolClosed())},500)}!function(){"use strict";const e={isOpen:!1,orientation:void 0},o=(e,o)=>{window.dispatchEvent(new CustomEvent("devtoolschange",{detail:{isOpen:e,orientation:o}}))},n=({emitEvents:n=!0}={})=>{const i=window.outerWidth-window.innerWidth>160,t=window.outerHeight-window.innerHeight>160,d=i?"vertical":"horizontal";t&&i||!(window.Firebug&&window.Firebug.chrome&&window.Firebug.chrome.isInitialized||i||t)?(e.isOpen&&n&&o(!1,void 0),e.isOpen=!1,e.orientation=void 0):(e.isOpen&&e.orientation===d||!n||o(!0,d),e.isOpen=!0,e.orientation=d)};n({emitEvents:!1}),setInterval(n,500),"undefined"!=typeof module&&module.exports?module.exports=e:window.devtools=e}(),simpleDisableDevTool(),advanceDisableDevTool();