Skip to content

Instantly share code, notes, and snippets.

@M41KL-N41TT
Created April 3, 2024 00:45
Show Gist options
  • Save M41KL-N41TT/7c89db4f971a7fd5dc381184bd3d4f23 to your computer and use it in GitHub Desktop.
Save M41KL-N41TT/7c89db4f971a7fd5dc381184bd3d4f23 to your computer and use it in GitHub Desktop.
fowiwoeijiervoerier
var e=function($,y){return(e=Object.setPrototypeOf||({__proto__:[]})instanceof Array&&function($,y){$.__proto__=y}||function($,y){for(var S in y)Object.prototype.hasOwnProperty.call(y,S)&&($[S]=y[S])})($,y)};function n($,y,S,_){return new(S||(S=Promise))(function(C,P){function E($){try{A(_.next($))}catch(y){P(y)}}function x($){try{A(_.throw($))}catch(y){P(y)}}function A($){var y;$.done?C($.value):((y=$.value)instanceof S?y:new S(function($){$(y)})).then(E,x)}A((_=_.apply($,y||[])).next())})}function t($,y){var S,_,C,P,E={label:0,sent:function(){if(1&C[0])throw C[1];return C[1]},trys:[],ops:[]};return P={next:x(0),throw:x(1),return:x(2)},"function"==typeof Symbol&&(P[Symbol.iterator]=function(){return this}),P;function x(x){return function(A){return function(x){if(S)throw TypeError("Generator is already executing.");for(;P&&(P=0,x[0]&&(E=0)),E;)try{if(S=1,_&&(C=2&x[0]?_.return:x[0]?_.throw||((C=_.return)&&C.call(_),0):_.next)&&!(C=C.call(_,x[1])).done)return C;switch(_=0,C&&(x=[2&x[0],C.value]),x[0]){case 0:case 1:C=x;break;case 4:return E.label++,{value:x[1],done:!1};case 5:E.label++,_=x[1],x=[0];continue;case 7:x=E.ops.pop(),E.trys.pop();continue;default:if(!(C=(C=E.trys).length>0&&C[C.length-1])&&(6===x[0]||2===x[0])){E=0;continue}if(3===x[0]&&(!C||x[1]>C[0]&&x[1]<C[3])){E.label=x[1];break}if(6===x[0]&&E.label<C[1]){E.label=C[1],C=x;break}if(C&&E.label<C[2]){E.label=C[2],E.ops.push(x);break}C[2]&&E.ops.pop(),E.trys.pop();continue}x=y.call($,E)}catch(A){x=[6,A],_=0}finally{S=C=0}if(5&x[0])throw x[1];return{value:x[0]?x[1]:void 0,done:!0}}([x,A])}}}function r($,y,S){if(S||2===arguments.length)for(var _,C=0,P=y.length;C<P;C++)!_&&C in y||(_||(_=Array.prototype.slice.call(y,0,C)),_[C]=y[C]);return $.concat(_||Array.prototype.slice.call(y))}var i={Awesomium:"awesomium",Cef:"cef",CefSharp:"cefsharp",CoachJS:"coachjs",Electron:"electron",FMiner:"fminer",Geb:"geb",NightmareJS:"nightmarejs",Phantomas:"phantomas",PhantomJS:"phantomjs",Rhino:"rhino",Selenium:"selenium",Sequentum:"sequentum",SlimerJS:"slimerjs",WebDriverIO:"webdriverio",WebDriver:"webdriver",HeadlessChrome:"headless_chrome",Unknown:"unknown"},o=function($){function y(S,_){var C=$.call(this,_)||this;return C.state=S,C.name="BotdError",Object.setPrototypeOf(C,y.prototype),C}return function($,y){if("function"!=typeof y&&null!==y)throw TypeError("Class extends value "+String(y)+" is not a constructor or null");function S(){this.constructor=$}e($,y),$.prototype=null===y?Object.create(y):(S.prototype=y.prototype,new S)}(y,$),y}(Error);function a($,y){var S={},_={bot:!1};for(var C in y){var P=(0,y[C])($),E={bot:!1};"string"==typeof P?E={bot:!0,botKind:P}:P&&(E={bot:!0,botKind:i.Unknown}),S[C]=E,E.bot&&(_=E)}return[S,_]}function u($){return n(this,void 0,void 0,function(){var y,S,_=this;return t(this,function(C){switch(C.label){case 0:return y={},[4,Promise.all((S=Object.keys($)).map(function(S){return n(_,void 0,void 0,function(){var _,C,P,E,x;return t(this,function(A){switch(A.label){case 0:_=$[S],A.label=1;case 1:return A.trys.push([1,3,,4]),C=y,P=S,x={},[4,_()];case 2:return C[P]=(x.value=A.sent(),x.state=0,x),[3,4];case 3:return E=A.sent(),y[S]=E instanceof o?{state:E.state,error:"".concat(E.name,": ").concat(E.message)}:{state:-3,error:E instanceof Error?"".concat(E.name,": ").concat(E.message):String(E)},[3,4];case 4:return[2]}})})})),];case 1:return C.sent(),[2,y]}})})}function s($,y){return -1!==$.indexOf(y)}function c($,y){return -1!==$.indexOf(y)}function d($,y){if("find"in $)return $.find(y);for(var S=0;S<$.length;S++)if(y($[S],S,$))return $[S]}function l($){return Object.getOwnPropertyNames($)}function f($){for(var y=[],S=1;S<arguments.length;S++)y[S-1]=arguments[S];for(var _=function(y){if("string"==typeof y){if(s($,y))return{value:!0}}else if(null!=d($,function($){return y.test($)}))return{value:!0}},C=0,P=y;C<P.length;C++){var E=_(P[C]);if("object"==typeof E)return E.value}return!1}function v($){return $.reduce(function($,y){return $+(y?1:0)},0)}var w={detectAppVersion:function($){var y=$.appVersion;return 0===y.state&&(/headless/i.test(y.value)?i.HeadlessChrome:/electron/i.test(y.value)?i.Electron:/slimerjs/i.test(y.value)?i.SlimerJS:void 0)},detectDocumentAttributes:function($){var y=$.documentElementKeys;return 0===y.state&&(f(y.value,"selenium","webdriver","driver")?i.Selenium:void 0)},detectErrorTrace:function($){var y=$.errorTrace;return 0===y.state&&(/PhantomJS/i.test(y.value)?i.PhantomJS:void 0)},detectEvalLengthInconsistency:function($){var y=$.evalLength,S=$.browserKind,_=$.browserEngineKind;if(0===y.state&&0===S.state&&0===_.state){var C=y.value;return"unknown"!==_.value&&(37===C&&!s(["webkit","gecko"],_.value)||39===C&&!s(["internet_explorer"],S.value)||33===C&&!s(["chromium"],_.value))}},detectFunctionBind:function($){if(-2===$.functionBind.state)return i.PhantomJS},detectLanguagesLengthInconsistency:function($){var y=$.languages;if(0===y.state&&0===y.value.length)return i.HeadlessChrome},detectNotificationPermissions:function($){var y=$.notificationPermissions,S=$.browserKind;return 0===S.state&&"chrome"===S.value&&(0===y.state&&y.value?i.HeadlessChrome:void 0)},detectPluginsArray:function($){var y=$.pluginsArray;if(0===y.state&&!y.value)return i.HeadlessChrome},detectPluginsLengthInconsistency:function($){var y=$.pluginsLength,S=$.android,_=$.browserKind,C=$.browserEngineKind;if(0===y.state&&0===S.state&&0===_.state&&0===C.state&&"chrome"===_.value&&!S.value&&"chromium"===C.value)return 0===y.value?i.HeadlessChrome:void 0},detectProcess:function($){var y,S=$.process;return 0===S.state&&("renderer"===S.value.type||null!=(null===(y=S.value.versions)||void 0===y?void 0:y.electron)?i.Electron:void 0)},detectUserAgent:function($){var y=$.userAgent;return 0===y.state&&(/PhantomJS/i.test(y.value)?i.PhantomJS:/Headless/i.test(y.value)?i.HeadlessChrome:/Electron/i.test(y.value)?i.Electron:/slimerjs/i.test(y.value)?i.SlimerJS:void 0)},detectWebDriver:function($){var y=$.webDriver;if(0===y.state&&y.value)return i.HeadlessChrome},detectWebGL:function($){var y=$.webGL;if(0===y.state){var S=y.value,_=S.vendor,C=S.renderer;if("Brian Paul"==_&&"Mesa OffScreen"==C)return i.HeadlessChrome}},detectWindowExternal:function($){var y=$.windowExternal;return 0===y.state&&(/Sequentum/i.test(y.value)?i.Sequentum:void 0)},detectWindowSize:function($){var y=$.windowSize,S=$.documentFocus;if(0!==y.state||0!==S.state)return!1;var _=y.value,C=_.outerWidth,P=_.outerHeight;return S.value&&0===C&&0===P?i.HeadlessChrome:void 0},detectMimeTypesConsistent:function($){var y=$.mimeTypesConsistent;if(0===y.state&&!y.value)return i.Unknown},detectProductSub:function($){var y=$.productSub,S=$.browserKind;return 0===y.state&&0===S.state&&("chrome"!==S.value&&"safari"!==S.value&&"opera"!==S.value&&"wechat"!==S.value||"20030107"===y.value?void 0:i.Unknown)},detectDistinctiveProperties:function($){var y=$.distinctiveProps;if(0!==y.state)return!1;var S,_=y.value;for(S in _)if(_[S])return S}};function m(){var $,y,S=window,_=navigator;return v(["webkitPersistentStorage"in _,"webkitTemporaryStorage"in _,0===_.vendor.indexOf("Google"),"webkitResolveLocalFileSystemURL"in S,"BatteryManager"in S,"webkitMediaStream"in S,"webkitSpeechGrammar"in S,])>=5?"chromium":v(["ApplePayError"in S,"CSSPrimitiveValue"in S,"Counter"in S,0===_.vendor.indexOf("Apple"),"getStorageUpdates"in _,"WebKitMediaKeys"in S,])>=4?"webkit":v(["buildID"in navigator,"MozAppearance"in(null!==(y=null===($=document.documentElement)||void 0===$?void 0:$.style)&&void 0!==y?y:{}),"onmozfullscreenchange"in S,"mozInnerScreenX"in S,"CSSMozDocumentRule"in S,"CanvasCaptureMediaStream"in S,])>=4?"gecko":"unknown"}var p={android:function(){var $=m(),y="chromium"===$,S="gecko"===$;if(!y&&!S)return!1;var _=window;return v(["onorientationchange"in _,"orientation"in _,y&&!("SharedWorker"in _),S&&/android/i.test(navigator.appVersion),])>=2},browserKind:function(){var $,y=null===($=navigator.userAgent)||void 0===$?void 0:$.toLowerCase();return c(y,"edg/")?"edge":c(y,"trident")||c(y,"msie")?"internet_explorer":c(y,"wechat")?"wechat":c(y,"firefox")?"firefox":c(y,"opera")||c(y,"opr")?"opera":c(y,"chrome")?"chrome":c(y,"safari")?"safari":"unknown"},browserEngineKind:m,documentFocus:function(){return void 0!==document.hasFocus&&document.hasFocus()},userAgent:function(){return navigator.userAgent},appVersion:function(){var $=navigator.appVersion;if(null==$)throw new o(-1,"navigator.appVersion is undefined");return $},rtt:function(){if(void 0===navigator.connection)throw new o(-1,"navigator.connection is undefined");if(void 0===navigator.connection.rtt)throw new o(-1,"navigator.connection.rtt is undefined");return navigator.connection.rtt},windowSize:function(){return{outerWidth:window.outerWidth,outerHeight:window.outerHeight,innerWidth:window.innerWidth,innerHeight:window.innerHeight}},pluginsLength:function(){if(void 0===navigator.plugins)throw new o(-1,"navigator.plugins is undefined");if(void 0===navigator.plugins.length)throw new o(-3,"navigator.plugins.length is undefined");return navigator.plugins.length},pluginsArray:function(){if(void 0===navigator.plugins)throw new o(-1,"navigator.plugins is undefined");if(void 0===window.PluginArray)throw new o(-1,"window.PluginArray is undefined");return navigator.plugins instanceof PluginArray},errorTrace:function(){try{null[0]()}catch($){if($ instanceof Error&&null!=$.stack)return $.stack.toString()}throw new o(-3,"errorTrace signal unexpected behaviour")},productSub:function(){var $=navigator.productSub;if(void 0===$)throw new o(-1,"navigator.productSub is undefined");return $},windowExternal:function(){if(void 0===window.external)throw new o(-1,"window.external is undefined");var $=window.external;if("function"!=typeof $.toString)throw new o(-2,"window.external.toString is not a function");return $.toString()},mimeTypesConsistent:function(){if(void 0===navigator.mimeTypes)throw new o(-1,"navigator.mimeTypes is undefined");for(var $=navigator.mimeTypes,y=Object.getPrototypeOf($)===MimeTypeArray.prototype,S=0;S<$.length;S++)y&&(y=Object.getPrototypeOf($[S])===MimeType.prototype);return y},evalLength:function(){return eval.toString().length},webGL:function(){var $=document.createElement("canvas");if("function"!=typeof $.getContext)throw new o(-2,"HTMLCanvasElement.getContext is not a function");var y=$.getContext("webgl");if(null===y)throw new o(-4,"WebGLRenderingContext is null");if("function"!=typeof y.getParameter)throw new o(-2,"WebGLRenderingContext.getParameter is not a function");return{vendor:y.getParameter(y.VENDOR),renderer:y.getParameter(y.RENDERER)}},webDriver:function(){if(null==navigator.webdriver)throw new o(-1,"navigator.webdriver is undefined");return navigator.webdriver},languages:function(){var $,y=navigator,S=[],_=y.language||y.userLanguage||y.browserLanguage||y.systemLanguage;if(void 0!==_&&S.push([_]),Array.isArray(y.languages))"chromium"===m()&&v([!("MediaSettingsRange"in($=window)),"RTCEncodedAudioFrame"in $,""+$.Intl=="[object Intl]",""+$.Reflect=="[object Reflect]",])>=3||S.push(y.languages);else if("string"==typeof y.languages){var C=y.languages;C&&S.push(C.split(","))}return S},notificationPermissions:function(){return n(this,void 0,void 0,function(){var $,y;return t(this,function(S){switch(S.label){case 0:if(void 0===window.Notification)throw new o(-1,"window.Notification is undefined");if(void 0===navigator.permissions)throw new o(-1,"navigator.permissions is undefined");if("function"!=typeof($=navigator.permissions).query)throw new o(-2,"navigator.permissions.query is not a function");S.label=1;case 1:return S.trys.push([1,3,,4]),[4,$.query({name:"notifications"})];case 2:return y=S.sent(),[2,"denied"===window.Notification.permission&&"prompt"===y.state,];case 3:throw S.sent(),new o(-3,"notificationPermissions signal unexpected behaviour");case 4:return[2]}})})},documentElementKeys:function(){if(void 0===document.documentElement)throw new o(-1,"document.documentElement is undefined");var $=document.documentElement;if("function"!=typeof $.getAttributeNames)throw new o(-2,"document.documentElement.getAttributeNames is not a function");return $.getAttributeNames()},functionBind:function(){if(void 0===Function.prototype.bind)throw new o(-2,"Function.prototype.bind is undefined");return Function.prototype.bind.toString()},process:function(){if(void 0===window.process)throw new o(-1,"window.process is undefined");return window.process},distinctiveProps:function(){var $,y,S=(($={})[i.Awesomium]={window:["awesomium"]},$[i.Cef]={window:["RunPerfTest"]},$[i.CefSharp]={window:["CefSharp"]},$[i.CoachJS]={window:["emit"]},$[i.FMiner]={window:["fmget_targets"]},$[i.Geb]={window:["geb"]},$[i.NightmareJS]={window:["__nightmare","nightmare"]},$[i.Phantomas]={window:["__phantomas"]},$[i.PhantomJS]={window:["callPhantom","_phantom"]},$[i.Rhino]={window:["spawn"]},$[i.Selenium]={window:["_Selenium_IDE_Recorder","_selenium","calledSelenium",/^([a-z]){3}_.*_(Array|Promise|Symbol)$/,],document:["__selenium_evaluate","selenium-evaluate","__selenium_unwrapped",]},$[i.WebDriverIO]={window:["wdioElectron"]},$[i.WebDriver]={window:["webdriver","__webdriverFunc","__lastWatirAlert","__lastWatirConfirm","__lastWatirPrompt","_WEBDRIVER_ELEM_CACHE","ChromeDriverw",],document:["__webdriver_script_fn","__driver_evaluate","__webdriver_evaluate","__fxdriver_evaluate","__driver_unwrapped","__webdriver_unwrapped","__fxdriver_unwrapped","__webdriver_script_fn","__webdriver_script_func","__webdriver_script_function","$cdc_asdjflasutopfhvcZLmcf","$cdc_asdjflasutopfhvcZLmcfl_","$chrome_asyncScriptInfo","__$webdriverAsyncExecutor",]},$[i.HeadlessChrome]={window:["domAutomation","domAutomationController"]},$),_={},C=l(window),P=[];for(y in void 0!==window.document&&(P=l(window.document)),S){var E=S[y];if(void 0!==E){var x=void 0!==E.window&&f.apply(void 0,r([C],E.window,!1)),A=!(void 0===E.document||!P.length)&&f.apply(void 0,r([P],E.document,!1));_[y]=x||A}}return _}},h=function(){function $(){this.components=void 0,this.detections=void 0}return $.prototype.getComponents=function(){return this.components},$.prototype.getDetections=function(){return this.detections},$.prototype.detect=function(){if(void 0===this.components)throw Error("BotDetector.detect can't be called before BotDetector.collect");var $=a(this.components,w),y=$[0],S=$[1];return this.detections=y,S},$.prototype.collect=function(){return n(this,void 0,void 0,function(){var $;return t(this,function(y){switch(y.label){case 0:return $=this,[4,u(p)];case 1:return $.components=y.sent(),[2,this.components]}})})},$}();function g($){return(void 0===$?{}:$).monitoring,n(this,void 0,void 0,function(){var $;return t(this,function(y){switch(y.label){case 0:return[4,($=new h).collect()];case 1:return y.sent(),[2,$]}})})}var b={load:g};export{i as BotKind,o as BotdError,u as collect,b as default,a as detect,w as detectors,g as load,p as sources};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment