KingNish commited on
Commit
8bf0097
1 Parent(s): a423750

Create secure.js

Browse files
Files changed (1) hide show
  1. secure.js +1 -0
secure.js ADDED
@@ -0,0 +1 @@
 
 
1
+ (function(a,b){"object"==typeof exports&&"undefined"!=typeof module?module.exports=b():"function"==typeof define&&define.amd?define(b):(a="undefined"==typeof globalThis?a||self:globalThis,a.DisableDevtool=b())})(this,function(){"use strict";function a(){if(p.redirectUrl)window.location.href=p.redirectUrl;else if(p.replacementHTML)try{document.documentElement.innerHTML=p.replacementHTML}catch(a){document.documentElement.innerText=p.replacementHTML}else{try{window.opener=null,window.open("","_self"),window.close(),window.history.back()}catch(a){console.log(a)}setTimeout(function(){window.location.href=p.timeoutRedirectUrl||`https://theajack.github.io/disable-devtool/404.html?h=${encodeURIComponent(location.host)}`},500)}}function b(a={}){for(const b in p)void 0!==a[b]&&(s(p[b])===s(a[b])||-1!==q.indexOf(b))&&(p[b]=a[b]);"function"==typeof p.onDevToolClose&&!0===p.stopIntervalOnOpen&&(p.stopIntervalOnOpen=!1,console.warn("stopIntervalOnOpen is invalid when using onDevToolClose"))}function c(){const a=navigator.userAgent.toLowerCase(),b="number"==typeof navigator.maxTouchPoints?1<navigator.maxTouchPoints:/android|iphone|ipad|ipod|arch/i.test(navigator.platform.toLowerCase())||/(iphone|ipad|ipod|ios|android)/i.test(a),c=!!window.top&&window!==window.top,d=a.includes("qqbrowser"),e=a.includes("firefox"),f=a.includes("macintosh"),g=a.includes("edge"),h=g&&!a.includes("chrome"),i=h||a.includes("trident")||a.includes("msie"),j=a.includes("crios"),k=a.includes("edgios"),l=a.includes("chrome")||j,m=!b&&/(googlebot|baiduspider|bingbot|applebot|petalbot|yandexbot|bytespider|chrome\-lighthouse|moto g power)/i.test(a);Object.assign(r,{isWithinIframe:c,isPC:!b,isQQBrowser:d,isFirefox:e,isMacOS:f,isEdge:g,isLegacyEdge:h,isIE:i,isIOSChrome:j,isIOSEdge:k,isChrome:l,isSearchBot:m,isMobile:b})}function d(){const a={};for(let b=0;500>b;b++)a[`${b}`]=`${b}`;const b=[];for(let c=0;50>c;c++)b.push(a);return b}function e(){p.clearConsoleOnInit&&x()}function f(a){z[a]=!1}function g(){for(const a in z)if(z[a])return y=!0;return y=!1}function h(){const a=p.ignoreUrlPatterns;if(a){if("function"==typeof a)return a();if(0!==a.length){const b=location.href;if(A===b)return B;A=b;for(const c of a)if("string"==typeof c&&b.includes(c)||c instanceof RegExp&&c.test(b))return B=!0}}return B=!1}function i(a){const b=r.isMacOS,c=b?a=>a.metaKey&&a.altKey&&(73===a.keyCode||105===a.keyCode):a=>a.ctrlKey&&a.shiftKey&&(73===a.keyCode||105===a.keyCode),d=b?a=>a.metaKey&&a.altKey&&85===a.keyCode||a.metaKey&&83===a.keyCode:a=>a.ctrlKey&&(83===a.keyCode||85===a.keyCode);a.addEventListener("keydown",function(b){const e=b.keyCode||b.which;if(123===e||c(b)||d(b))return l(a,b)},!0),p.disableRightClick&&a.addEventListener("contextmenu",function(b){if("touch"!==b.pointerType)return l(a,b)},!1),p.disableTextSelect&&j(a,"selectstart"),p.disableCopy&&j(a,"copy"),p.disableCut&&j(a,"cut"),p.disablePaste&&j(a,"paste")}function j(a,b){a.addEventListener(b,k)}function k(a){if(!h()&&!K.isDetectionSuspended)return a.preventDefault(),!1}function l(a,b){if(!h()&&!K.isDetectionSuspended)return(b=b||a.event).returnValue=!1,b.preventDefault(),!1}function m(){H=setInterval(()=>{if(!(K.isDetectionSuspended||h())){for(const a of F)f(a.type),a.detect(J++);if(e(),"function"==typeof p.onDevToolClose){const a=y;!g()&&a&&p.onDevToolClose()}}},p.checkInterval)}function n(){clearInterval(H)}function o(a){let b=0;for(let c=0;c<a.length;c++)b=(b<<5)-b+a.charCodeAt(c),b|=0;return b.toString(16)}const p={onDevToolOpen:a,onDevToolClose:null,redirectUrl:"",timeoutRedirectUrl:"",urlTokenParam:"ddtk",checkInterval:500,disableRightClick:!0,stopCheckAfter:5e3,stopIntervalOnOpen:!1,enabledDetectors:[0,1,3,4,5,6,7],clearConsoleOnInit:!0,disableTextSelect:!1,disableCopy:!1,disableCut:!1,disablePaste:!1,ignoreUrlPatterns:null,disableDevToolsInParentFrames:!1,detectSearchEngineBots:!1,replacementHTML:""},q=["enabledDetectors","onDevToolClose","ignoreUrlPatterns"],r={isWithinIframe:!1,isPC:!1,isQQBrowser:!1,isFirefox:!1,isMacOS:!1,isEdge:!1,isLegacyEdge:!1,isIE:!1,isIOSChrome:!1,isIOSEdge:!1,isChrome:!1,isSearchBot:!1,isMobile:!1},s=a=>"object"==typeof a&&null!==a,t=()=>new Date().getTime(),u=a=>{const b=t();return a(),t()-b};let v=console.log,w=console.table,x=console.clear;r.isIE&&(v=(...a)=>console.log(...a),w=(...a)=>console.table(...a),x=()=>console.clear());let y=!1;const z={};let A="",B=!1;const C={RegexToString:0,DefinePropertyID:1,WindowSize:2,DateToString:3,FunctionToString:4,DebuggerStatement:5,Performance:6,ExternalLibrary:7};class D{constructor({type:a,isEnabled:b=!0}){this.type=C.Unknown,this.isEnabled=!0,this.type=a,this.isEnabled=b,this.isEnabled&&(F.push(this),this.init())}onDevToolOpen(){console.warn(`DevTool usage is prohibited! [Detector: ${this.type}]`),p.stopIntervalOnOpen&&n(),clearTimeout(I),p.onDevToolOpen(this.type,a),z[this.type]=!0}init(){}detect(){}}class E extends D{constructor(){super({type:C.ExternalLibrary})}init(){}detect(){(window.eruda&&window.eruda._devTools&&window.eruda._devTools._isShow||window._vcOrigConsole&&window.document.querySelector("#__vconsole.vc-toggle"))&&this.onDevToolOpen()}static isExternalLibraryInUse(){return!!window.eruda||!!window._vcOrigConsole}}const F=[],G={[C.RegexToString]:class a extends D{constructor(){super({type:C.RegexToString,isEnabled:r.isQQBrowser||r.isFirefox})}init(){this.lastDetection=0,this.regex=/./,v(this.regex),this.regex.toString=()=>{if(r.isQQBrowser){const a=t();this.lastDetection&&100>a-this.lastDetection?this.onDevToolOpen():this.lastDetection=a}else r.isFirefox&&this.onDevToolOpen();return""}}detect(){v(this.regex)}},[C.DefinePropertyID]:class a extends D{constructor(){super({type:C.DefinePropertyID})}init(){this.div=document.createElement("div"),this.div.__defineGetter__("id",()=>this.onDevToolOpen()),Object.defineProperty(this.div,"id",{get:()=>this.onDevToolOpen()})}detect(){v(this.div)}},[C.WindowSize]:class a extends D{constructor(){super({type:C.WindowSize,isEnabled:!r.isWithinIframe&&!r.isEdge})}init(){this.checkWindowSize(),window.addEventListener("resize",()=>{setTimeout(()=>this.checkWindowSize(),100)},!0)}detect(){}checkWindowSize(){const a=window.devicePixelRatio||window.screen&&window.screen.deviceXDPI&&window.screen.logicalXDPI&&window.screen.deviceXDPI/window.screen.logicalXDPI;if(!1!==a){const b=200<window.outerWidth-window.innerWidth*a,c=300<window.outerHeight-window.innerHeight*a;if(b||c)return this.onDevToolOpen(),!1;f(this.type)}return!0}},[C.DateToString]:class a extends D{constructor(){super({type:C.DateToString,isEnabled:!r.isIOSChrome&&!r.isIOSEdge})}init(){this.modifyCount=0,this.date=new Date,this.date.toString=()=>(this.modifyCount++,"")}detect(){this.modifyCount=0,v(this.date),e(),2<=this.modifyCount&&this.onDevToolOpen()}},[C.FunctionToString]:class a extends D{constructor(){super({type:C.FunctionToString,isEnabled:!r.isIOSChrome&&!r.isIOSEdge})}init(){this.modifyCount=0,this.func=function(){},this.func.toString=()=>(this.modifyCount++,"")}detect(){this.modifyCount=0,v(this.func),e(),2<=this.modifyCount&&this.onDevToolOpen()}},[C.DebuggerStatement]:class a extends D{constructor(){super({type:C.DebuggerStatement,isEnabled:r.isIOSChrome||r.isIOSEdge})}detect(){const a=t();debugger;100<t()-a&&this.onDevToolOpen()}},[C.Performance]:class a extends D{constructor(){super({type:C.Performance,isEnabled:r.isChrome||!r.isMobile})}init(){this.maxPrintTime=0,this.largeArray=d()}detect(){const a=u(()=>w(this.largeArray)),b=u(()=>v(this.largeArray));return this.maxPrintTime=Math.max(this.maxPrintTime,b),e(),0!==a&&0!==this.maxPrintTime&&void(a>10*this.maxPrintTime&&this.onDevToolOpen())}},[C.ExternalLibrary]:E};let H=0,I=0,J=0;const K=Object.assign(function(a={}){function d(a=""){return{success:!a,reason:a}}if(K.isRunning)return d("already running");c(),x=r.isIE?console.clear:console.clear,b(a);const e=new URLSearchParams(window.location.search).get(p.urlTokenParam);if(e&&o(e)===o(window.location.href))return d("token passed");if(p.detectSearchEngineBots&&r.isSearchBot)return d("search bot");K.isRunning=!0,m();const f=window.top,g=window.parent;if(p.disableDevToolsInParentFrames&&f&&g&&f!==window){for(let a=window;a!==f;)i(a),a=a.parent;i(f)}i(window);const h="all"===p.enabledDetectors?Object.keys(G):p.enabledDetectors;return h.forEach(a=>{new G[a]}),I=setTimeout(function(){r.isPC||E.isExternalLibraryInUse()||n()},p.stopCheckAfter),d()},{isRunning:!1,isDetectionSuspended:!1,calculateMD5:o,version:"0.0.1",DetectorType:C,isDevToolOpened:g}),L=function(){if("undefined"==typeof window||!window.document)return null;const a=document.querySelector("[secura-auto]");if(!a)return null;const b=["disable-menu","disable-select","disable-copy","disable-cut","disable-paste","clear-log"],c=["interval"],d={};["md5","url","tk-name","detectors",...b,...c].forEach(e=>{const f=a.getAttribute(e);if(null!==f){const a=e.split("-").map((a,b)=>0===b?a:a.charAt(0).toUpperCase()+a.slice(1)).join("");d[a]=c.includes(e)?parseInt(f):b.includes(e)?"false"!==f:"detectors"===e&&"all"!==f?f.split(" "):f}});const e={md5:"urlToken",url:"redirectUrl","tk-name":"urlTokenParam",disableMenu:"disableRightClick",disableSelect:"disableTextSelect",clearLog:"clearConsoleOnInit",interval:"checkInterval"};for(const a in e)void 0!==d[a]&&(d[e[a]]=d[a],delete d[a]);return d}();return L&&K(L),K});