-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeno.js
2 lines (2 loc) · 4.25 KB
/
deno.js
1
2
"use strict";import{serve}from"https://deno.land/std/http/server.ts";let pW="0.0",pV="Deno";(()=>{var b={"5.1":"Windows XP","5.2":"Windows XP","6.0":"Windows Vista","6.1":"Windows 7","6.2":"Windows 8","6.3":"Windows 8.1","10.0":"Windows 10","11.0":"Windows 11"},c=class extends Array{constructor(n){super();let r=this;n.split(".").forEach(function(i,e){r[e]=parseInt(i)})}toString(){let n="";return this.forEach(function(r,i){n+=i!=0?".":"",n+=r}),n}},f=class{constructor(n,r){this.name=n,this.version=new c(r)}},p=function(s){let n=`${s} `,r=[],i={},e={isBrowser:!1,platform:"",deviceArch:"na",deviceModel:"",wowState:"na",platformName:"",mobile:!1,agent:"",agentVer:[0],altVer:[0],sysVer:[0]},a=0,o="",h="",l=[""];return Array.from(n).forEach(function(t){switch(a){case 0:{t=="/"?(o=o.trim(),a=1):t==" "?(r.push(new f(o,"0")),o=""):o+=t;break}case 1:{t!=" "?h+=t:(r.push(new f(o,h)),o="",h="",a=2);break}case 2:{t=="("?a=3:(o+=t,a=0);break}case 3:{t==")"?(l.forEach(function(d,m,v){v[m]=d.trim()}),r[r.length-1].platRaw=l,l=[""],a=0):t==";"?l.push(""):l[l.length-1]+=t;break}}}),r.forEach(function(t){t?.name?.length>0&&(i[t.name.toLowerCase()]=t)}),i.mozilla?(e.isBrowser=!0,i.mozilla.platRaw.forEach(function(t,d,m){switch(t.indexOf("Windows NT ")>-1&&(e.platform="windows",e.platformName=b[t.slice(11)],e.sysVer=new c(t.slice(11)),e.deviceArch="i386"),t){case"Linux":{e.platform="linux",e.platformName="Linux";break}case"Win64":{e.deviceArch="amd64";break}case"Windows NT 5.1":{e.deviceArch="i386";break}case"Windows NT 5.2":{e.deviceArch="amd64";break}case"WOW64":{e.wowState="wow64",e.deviceArch="amd64";break}case"x64":{e.wowState="x64",e.deviceArch="amd64";break}default:t.indexOf("rv:")>-1?e.altVer=new c(t.slice(3)):t.indexOf("Android ")>-1?(e.platformName="Android",e.sysVer=new c(t.slice(8))):d+1==m.length?e.deviceModel=t:console.error(`Unparsed string "${t}" at Mozilla:${d}`)}}),i.mobile&&(e.mobile=!0),i.firefox?(e.agentVer=i.firefox.version,e.agent="Firefox"):i.chrome?(e.agentVer=i.chrome.version,e.agent="Chrome"):i.safari&&(e.agentVer=i.safari.version,e.agent="Safari")):(e.agent=r[0].name,e.agentVer=r[0].version),e};var u=function(s=200,n="Lorem",r="Blank."){return new Response(`<!DOCTYPE html><head><meta content="true" name="HandheldFriendly"/><title>${n}</title><style>body{font-family:sans-serif;position:absolute;width:100%;height:100%;background:#fff;margin:0;display:flex;align-items:center;justify-content:center;color:#555}#a{width:max-content;max-width:min(450px,80vw)}#b{text-align:center!important;font-weight:bold;font-size:1.5em;color:#333}#c{color:#333}#a>div{hyphens:auto;text-align:justify;padding:4px}a{text-decoration:none}#d{color:#777;font-size:0.75em}pre{overflow:scroll;padding:2px}@media(prefers-color-scheme:dark){html{filter:invert(100%)}}</style></head><body lang="en"><div id="a"><div id="b">${n}</div><div>${r}</div><div id="d"><center>Cloud Hop v${pW}@${pV}</center></div></div></body>`,{status:s,headers:{Server:"Cloud Hop","Content-Type":"text/html","Accept-CH":"sec-ch-ua-full-version,sec-ch-ua-full-version-list"}})};var w=["N/A","Passed","Blocked","Suspicious"],x=["Ah, you seem to use ${browser}. No tests are performed.","All checks passed. Congrats!","Somepony is hiding themselves, how naughty:","Somepony is acting very suspicious:"],g=function(s){let n=0,r="",i=p(s.headers.get("user-agent"));if(console.info(`User agent object: ${JSON.stringify(i)}`),console.info(`User agent string: ${s.headers.get("user-agent")}`),i.agent=="Chrome"&&(!s.headers.has("sec-ch-ua")&&i.agentVer[0]>88&&(console.warn("Client hints stripped away intentionally."),n=3),i.platformName=="Android")){n=1;let a=0;i.agentVer.forEach(function(o){o==0&&a++}),a>1&&(i.agentVer[0]<103?(console.warn("Intentionally hiding version in user agent."),n=2):s.headers.has("sec-ch-ua")?s.headers.has("sec-ch-ua-full-version")&&s.headers.get("sec-ch-ua-full-version").indexOf(".0.0")>-1&&(console.warn("Intentionally hiding version in client hints."),n=2):(console.warn("No client hints available for versio detection."),n=2)),i.deviceModel.length<4&&(console.warn("Illegal device model."),n=2)}let e=u(200,w[n],`${x[n]}`.replace("${browser}",i.agent));return console.info(`Server-side detection: ${w[n].toLowerCase()}.`),e};serve(function(s,n){let r=n.remoteAddr.hostname;return g(s,r)});})();
//# sourceMappingURL=deno.js.map