-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfo-devtool.js
2 lines (2 loc) · 2.03 KB
/
fo-devtool.js
1
2
class FuckDevtool{constructor(e={}){this.interval=e.interval||0,this.redirectURL=e.redirectURL||"//github.com/WusThanhDieu",this.debug=e.debug||!1,this.preventDevTools=!1!==e.preventDevTools,this.checkBrowser=!1!==e.checkBrowser,this.enableDebugger=e.enableDebugger||!1,this.checkShortcuts=!1!==e.checkShortcuts,this._intervalID=null}#a(e){return Math.floor(1e3*e.Math.random())}#b(t){let r=navigator.userAgent.toLowerCase(),i=["chrome","cốc cốc","safari"].some(e=>r.includes(e));if(!i)return this.#c(),!1;if(t.chrome){let n=this.#a(t),o=this.#a(t),s=n,c=!1;try{let h=new t.Error;"function"==typeof Object.defineProperty&&Object.defineProperty(h,"stack",{configurable:!1,enumerable:!1,get:()=>(s+=o,"")}),console.debug(h),h.stack,n+o!==s&&(c=!0)}catch(l){this.debug&&console.error("Error in catch:",l)}return c}if(this.enableDebugger){let u=new Date,a=new Date;if(a-u>100)return!0}return!1}#d(){this.checkShortcuts&&(document.addEventListener("contextmenu",e=>{e.preventDefault()}),document.addEventListener("keydown",e=>{let t=e.key.toLowerCase(),r=e.ctrlKey||e.metaKey;(r&&["f12","u","s","p","i"].includes(t)||123===e.keyCode)&&e.preventDefault()}))}#e(d){this.debug&&(console.clear(),console.log(`%c ✨ [Fuck-Devtool] %c ${d} `,"color: #ffffff; background: rgb(255, 112, 67); padding:5px 0; border-radius: 5px 0 0 5px;","background:rgba(66, 66, 66, 0.85); padding:5px 0; border-radius: 0 5px 5px 0;"))}Fo(){if(!window)return!1;if(this.checkBrowser){let e=this.#b(window);e&&(this.#e("DevTools detected!"),window.location.replace(this.redirectURL),this.stop())}return!1}#c(){document.body.innerHTML=`
<h1 style="text-align: center; margin-top: 20%; font-size: 40px; color: red; pointer-events: none; user-select: none">BROWSER NOT SUPPORTED</h1>`}init(){this.#e("Initializing Fuck-Devtool..."),this.Fo(),this._intervalID=setInterval(()=>this.Fo(),this.interval),this.preventDevTools&&this.#d()}stop(){this._intervalID&&(clearInterval(this._intervalID),this._intervalID=null)}debounce(e,t){let r;return(...i)=>{r&&clearTimeout(r),r=setTimeout(()=>{e.apply(this,i)},t)}}}