Files
inzerosight/dist/chrome/content.js

56 lines
16 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

(function(){"use strict";const A={3:{unifier:"­",0:"",1:"",2:""},6:{unifier:"",0:"",1:"",2:"­",3:"",4:"",5:""},7:{unifier:"",0:"",1:"",2:"­",3:"",4:"",5:"",6:"\uFEFF"},encodeString:(n,e=7)=>Array.from(n,l=>(+e==7?ee(l):l.codePointAt(0)).toString(e).split("").map(p=>A[e][p]).join("")).join(A[e].unifier),encodeNumberArray:(n,e=7)=>n.map(l=>l.toString(e).split("").map(p=>A[e][p]).join("")).join(A[e].unifier),decodeToString:(n,e=7)=>A.decodeToNumberArray(n,e).map(l=>String.fromCodePoint(+e==7?te(l):l)).join(""),decodeToNumberArray:(n,e=7)=>n.split(A[e].unifier).map(l=>Array.from(l).map(p=>Object.keys(A[e]).find(b=>A[e][b]===p)).join("")).filter(Boolean).map(l=>parseInt(l,e))},Q="te aoinshrdlucmfwypvbgkjqxz.,!?'-:;()0123456789ETAOINSHRDLUCMFWYPVBGKJQXZ",H=[...new Set([...Q,...Array.from({length:95},(n,e)=>String.fromCharCode(e+32))])],Z=new Map(H.map((n,e)=>[n,e])),ee=n=>Z.get(n)??(n.codePointAt(0)<32?n.codePointAt(0)+95:n.codePointAt(0)),te=n=>n<95?H[n].codePointAt(0):n<127?n-95:n;function ne(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var D,L;function oe(){if(L)return D;L=1;function n(e={}){const l=e.bits||16,p=e.rounds||22,b=e.rightRotations||7,d=e.leftRotations||2,c=2**l,i=c-1,s=(a,o)=>a>>o|a<<l-o&i,h=(a,o)=>a<<o&i|a>>l-o,g=(a,o,t)=>(a=s(a,b),a=a+o&i,a^=t,o=h(o,d),o^=a,[a,o]),y=(a,o,t)=>(o^=a,o=s(o,d),a^=t,a=a-o&i,a=h(a,b),[a,o]);function k(a,o){let t=a[0],u=a[1],r=o[0],m=o.slice(1);[u,t]=g(u,t,r);for(let w=0;w<p-1;w++){const E=w%m.length;[m[E],r]=g(m[E],r,w),[u,t]=g(u,t,r)}return[t,u]}function I(a,o){let t=a[0],u=a[1],r=o[0],m=o.slice(1);for(let w=0;w<p-1;w++){const E=w%m.length;[m[E],r]=g(m[E],r,w)}for(let w=0;w<p;w++){const E=(p-2-w)%m.length;[u,t]=y(u,t,r),[m[E],r]=y(m[E],r,p-2-w)}return[t,u]}function f(a){return(o,t)=>{const u=a([o/c|0,o&i],t);return u[0]*c+u[1]}}return{encrypt:f(k),decrypt:f(I),encryptRaw:k,decryptRaw:I}}return D=n,D}var re=oe();const M=ne(re);var U,z;function G(){if(z)return U;z=1;const n="Input must be an string, Buffer or Uint8Array";function e(c){let i;if(c instanceof Uint8Array)i=c;else if(typeof c=="string")i=new TextEncoder().encode(c);else throw new Error(n);return i}function l(c){return Array.prototype.map.call(c,function(i){return(i<16?"0":"")+i.toString(16)}).join("")}function p(c){return(4294967296+c).toString(16).substring(1)}function b(c,i,s){let h=`
`+c+" = ";for(let g=0;g<i.length;g+=2){if(s===32)h+=p(i[g]).toUpperCase(),h+=" ",h+=p(i[g+1]).toUpperCase();else if(s===64)h+=p(i[g+1]).toUpperCase(),h+=p(i[g]).toUpperCase();else throw new Error("Invalid size "+s);g%6===4?h+=`
`+new Array(c.length+4).join(" "):g<i.length-2&&(h+=" ")}console.log(h)}function d(c,i,s){let h=new Date().getTime();const g=new Uint8Array(i);for(let k=0;k<i;k++)g[k]=k%256;const y=new Date().getTime();console.log("Generated random input in "+(y-h)+"ms"),h=y;for(let k=0;k<s;k++){const I=c(g),f=new Date().getTime(),a=f-h;h=f,console.log("Hashed in "+a+"ms: "+I.substring(0,20)+"..."),console.log(Math.round(i/(1<<20)/(a/1e3)*100)/100+" MB PER SECOND")}}return U={normalizeInput:e,toHex:l,debugPrint:b,testSpeed:d},U}var B,q;function ie(){if(q)return B;q=1;const n=G();function e(t,u,r){const m=t[u]+t[r];let w=t[u+1]+t[r+1];m>=4294967296&&w++,t[u]=m,t[u+1]=w}function l(t,u,r,m){let w=t[u]+r;r<0&&(w+=4294967296);let E=t[u+1]+m;w>=4294967296&&E++,t[u]=w,t[u+1]=E}function p(t,u){return t[u]^t[u+1]<<8^t[u+2]<<16^t[u+3]<<24}function b(t,u,r,m,w,E){const ye=h[w],Ee=h[w+1],ke=h[E],Ae=h[E+1];e(s,t,u),l(s,t,ye,Ee);let S=s[m]^s[t],T=s[m+1]^s[t+1];s[m]=T,s[m+1]=S,e(s,r,m),S=s[u]^s[r],T=s[u+1]^s[r+1],s[u]=S>>>24^T<<8,s[u+1]=T>>>24^S<<8,e(s,t,u),l(s,t,ke,Ae),S=s[m]^s[t],T=s[m+1]^s[t+1],s[m]=S>>>16^T<<16,s[m+1]=T>>>16^S<<16,e(s,r,m),S=s[u]^s[r],T=s[u+1]^s[r+1],s[u]=T>>>31^S<<1,s[u+1]=S>>>31^T<<1}const d=new Uint32Array([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),c=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3],i=new Uint8Array(c.map(function(t){return t*2})),s=new Uint32Array(32),h=new Uint32Array(32);function g(t,u){let r=0;for(r=0;r<16;r++)s[r]=t.h[r],s[r+16]=d[r];for(s[24]=s[24]^t.t,s[25]=s[25]^t.t/4294967296,u&&(s[28]=~s[28],s[29]=~s[29]),r=0;r<32;r++)h[r]=p(t.b,4*r);for(r=0;r<12;r++)b(0,8,16,24,i[r*16+0],i[r*16+1]),b(2,10,18,26,i[r*16+2],i[r*16+3]),b(4,12,20,28,i[r*16+4],i[r*16+5]),b(6,14,22,30,i[r*16+6],i[r*16+7]),b(0,10,20,30,i[r*16+8],i[r*16+9]),b(2,12,22,24,i[r*16+10],i[r*16+11]),b(4,14,16,26,i[r*16+12],i[r*16+13]),b(6,8,18,28,i[r*16+14],i[r*16+15]);for(r=0;r<16;r++)t.h[r]=t.h[r]^s[r]^s[r+16]}const y=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]);function k(t,u,r,m){if(t===0||t>64)throw new Error("Illegal output length, expected 0 < length <= 64");if(u&&u.length>64)throw new Error("Illegal key, expected Uint8Array with 0 < length <= 64");if(r&&r.length!==16)throw new Error("Illegal salt, expected Uint8Array with length is 16");if(m&&m.length!==16)throw new Error("Illegal personal, expected Uint8Array with length is 16");const w={b:new Uint8Array(128),h:new Uint32Array(16),t:0,c:0,outlen:t};y.fill(0),y[0]=t,u&&(y[1]=u.length),y[2]=1,y[3]=1,r&&y.set(r,32),m&&y.set(m,48);for(let E=0;E<16;E++)w.h[E]=d[E]^p(y,E*4);return u&&(I(w,u),w.c=128),w}function I(t,u){for(let r=0;r<u.length;r++)t.c===128&&(t.t+=t.c,g(t,!1),t.c=0),t.b[t.c++]=u[r]}function f(t){for(t.t+=t.c;t.c<128;)t.b[t.c++]=0;g(t,!0);const u=new Uint8Array(t.outlen);for(let r=0;r<t.outlen;r++)u[r]=t.h[r>>2]>>8*(r&3);return u}function a(t,u,r,m,w){r=r||64,t=n.normalizeInput(t),m&&(m=n.normalizeInput(m)),w&&(w=n.normalizeInput(w));const E=k(r,u,m,w);return I(E,t),f(E)}function o(t,u,r,m,w){const E=a(t,u,r,m,w);return n.toHex(E)}return B={blake2b:a,blake2bHex:o,blake2bInit:k,blake2bUpdate:I,blake2bFinal:f},B}var O,V;function se(){if(V)return O;V=1;const n=G();function e(f,a){return f[a]^f[a+1]<<8^f[a+2]<<16^f[a+3]<<24}function l(f,a,o,t,u,r){c[f]=c[f]+c[a]+u,c[t]=p(c[t]^c[f],16),c[o]=c[o]+c[t],c[a]=p(c[a]^c[o],12),c[f]=c[f]+c[a]+r,c[t]=p(c[t]^c[f],8),c[o]=c[o]+c[t],c[a]=p(c[a]^c[o],7)}function p(f,a){return f>>>a^f<<32-a}const b=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),d=new Uint8Array([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0]),c=new Uint32Array(16),i=new Uint32Array(16);function s(f,a){let o=0;for(o=0;o<8;o++)c[o]=f.h[o],c[o+8]=b[o];for(c[12]^=f.t,c[13]^=f.t/4294967296,a&&(c[14]=~c[14]),o=0;o<16;o++)i[o]=e(f.b,4*o);for(o=0;o<10;o++)l(0,4,8,12,i[d[o*16+0]],i[d[o*16+1]]),l(1,5,9,13,i[d[o*16+2]],i[d[o*16+3]]),l(2,6,10,14,i[d[o*16+4]],i[d[o*16+5]]),l(3,7,11,15,i[d[o*16+6]],i[d[o*16+7]]),l(0,5,10,15,i[d[o*16+8]],i[d[o*16+9]]),l(1,6,11,12,i[d[o*16+10]],i[d[o*16+11]]),l(2,7,8,13,i[d[o*16+12]],i[d[o*16+13]]),l(3,4,9,14,i[d[o*16+14]],i[d[o*16+15]]);for(o=0;o<8;o++)f.h[o]^=c[o]^c[o+8]}function h(f,a){if(!(f>0&&f<=32))throw new Error("Incorrect output length, should be in [1, 32]");const o=a?a.length:0;if(a&&!(o>0&&o<=32))throw new Error("Incorrect key length, should be in [1, 32]");const t={h:new Uint32Array(b),b:new Uint8Array(64),c:0,t:0,outlen:f};return t.h[0]^=16842752^o<<8^f,o>0&&(g(t,a),t.c=64),t}function g(f,a){for(let o=0;o<a.length;o++)f.c===64&&(f.t+=f.c,s(f,!1),f.c=0),f.b[f.c++]=a[o]}function y(f){for(f.t+=f.c;f.c<64;)f.b[f.c++]=0;s(f,!0);const a=new Uint8Array(f.outlen);for(let o=0;o<f.outlen;o++)a[o]=f.h[o>>2]>>8*(o&3)&255;return a}function k(f,a,o){o=o||32,f=n.normalizeInput(f);const t=h(o,a);return g(t,f),y(t)}function I(f,a,o){const t=k(f,a,o);return n.toHex(t)}return O={blake2s:k,blake2sHex:I,blake2sInit:h,blake2sUpdate:g,blake2sFinal:y},O}var _,W;function le(){if(W)return _;W=1;const n=ie(),e=se();return _={blake2b:n.blake2b,blake2bHex:n.blake2bHex,blake2bInit:n.blake2bInit,blake2bUpdate:n.blake2bUpdate,blake2bFinal:n.blake2bFinal,blake2s:e.blake2s,blake2sHex:e.blake2sHex,blake2sInit:e.blake2sInit,blake2sUpdate:e.blake2sUpdate,blake2sFinal:e.blake2sFinal},_}var X=le();const ce=M({bits:24,rounds:23,rightRotations:8,leftRotations:3});function ae(n){const e=X.blake2bHex(n,null,12);return[parseInt(e.slice(0,6),16),parseInt(e.slice(6,12),16),parseInt(e.slice(12,18),16),parseInt(e.slice(18,24),16)]}function ue(n,e){if(!n||n.length===0)return"";const l=n[0];return n.slice(1).map((b,d)=>{const c=l*16777216+(d&16777215),i=ce.encrypt(c,e),s=(b^i)>>>0;try{return String.fromCodePoint(s)}catch{return""}}).join("")}const fe=M();function de(n){const e=X.blake2bHex(n,null,8);return[parseInt(e.slice(0,4),16),parseInt(e.slice(4,8),16),parseInt(e.slice(8,12),16),parseInt(e.slice(12,16),16)]}function pe(n,e){return n.map(l=>{try{return String.fromCodePoint(fe.decrypt(l,e))}catch{return""}}).join("")}const N="­",x={3:"­",6:"­",7:"­"},K={1:"SPECK48_96CTR",2:"SPECK32_64ECB (insecure)"};Object.fromEntries(Object.entries(K).map(([n,e])=>[e,+n]));function be(n){let e=n.indexOf(N),l;for(;e!==-1&&(l=Object.keys(x).find(d=>n.startsWith(x[d],e)),!l);)e=n.indexOf(N,e+N.length);if(!l)return null;const p=n.slice(e+x[l].length),b=A[l].unifier+A[l][0];if(p.startsWith(b)){const c=Array.from(p.slice(b.length,b.length+3)).map(g=>Object.keys(A[l]).find(y=>A[l][y]===g)).join(""),i=K[parseInt(c,l)];if(!i)return{base:l,cipher:"PLAIN",payload:p,sigIdx:e,sigLen:x[l].length};const s=p.slice(b.length+3),h=x[l].length+b.length+3;return{base:l,cipher:i,payload:s,sigIdx:e,sigLen:h}}return{base:l,cipher:"PLAIN",payload:p,sigIdx:e,sigLen:x[l].length}}function $(n,e,l){const p=new Set(Object.values(A[e]));let b=l;for(;b<n.length&&p.has(n[b]);)b++;return b}let R,P;const C=new Set;function he(){if(R)return;R=document.createElement("div"),R.id="in0-host",P=R.attachShadow({mode:"open"});const n=document.createElement("style");n.textContent=`
.in0-wrap {
position: fixed;
pointer-events: auto;
z-index: 2147483647;
display: flex;
flex-direction: column;
align-items: center;
font-family: system-ui, -apple-system, sans-serif;
transition: opacity 0.1s ease;
}
.in0-btn {
background: #18191c;
color: #fff;
border: 1px solid #3a3b40;
border-radius: 4px;
font-size: 11px;
font-weight: 600;
padding: 4px 10px;
cursor: pointer;
box-shadow: 0 4px 12px rgba(0,0,0,0.5);
position: relative;
white-space: nowrap;
}
.in0-btn:hover {
border-color: #00b4d8;
box-shadow: 0 0 8px rgba(0,180,216,0.4);
}
.in0-badge {
position: absolute;
top: -6px;
right: -6px;
width: 15px;
height: 15px;
border-radius: 50%;
background: #00b4d8;
color: #fff;
font-size: 10px;
font-weight: 700;
display: flex;
align-items: center;
justify-content: center;
box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}
.in0-arrow {
width: 0;
height: 0;
border-left: 5px solid transparent;
border-right: 5px solid transparent;
border-top: 6px solid #18191c;
margin-top: -1px;
}
`,P.appendChild(n),(document.body||document.documentElement).appendChild(R)}function ge(n,e,l,p,b){for(const g of C)if(g.node===n&&g.start===l)return;he();const d=document.createElement("div");d.className="in0-wrap";const c=document.createElement("button");c.className="in0-btn",c.textContent=e.cipher==="PLAIN"?"Decode":"Decrypt";const i=document.createElement("span");i.className="in0-badge",i.textContent="Ø",c.appendChild(i);const s=document.createElement("div");s.className="in0-arrow",d.appendChild(c),d.appendChild(s),P.appendChild(d);const h={wrap:d,node:n,start:l,endNode:p,end:b};C.add(h),c.onclick=()=>me(h,e),Y(h)}function Y(n){const{wrap:e,node:l,start:p,endNode:b,end:d}=n;if(!l.isConnected||!b.isConnected){e.remove(),C.delete(n);return}const c=l.parentElement;if(!c||c.checkVisibility&&!c.checkVisibility({checkOpacity:!0,checkVisibilityCSS:!0})){e.style.display="none";return}const i=document.createRange();try{i.setStart(l,p),i.setEnd(b,Math.min(d,b.nodeValue.length))}catch{e.remove(),C.delete(n);return}let s=i.getBoundingClientRect();if(!s.width&&!s.height&&(s=c.getBoundingClientRect()),!s.width&&!s.height){e.style.display="none";return}if(s.bottom<0||s.top>window.innerHeight||s.right<0||s.left>window.innerWidth){e.style.display="none";return}let h=c;for(;h&&h!==document.body&&h!==document.documentElement;){const k=window.getComputedStyle(h);if(k.overflow!=="visible"||k.overflowX!=="visible"||k.overflowY!=="visible"){const I=h.getBoundingClientRect();if(s.bottom<I.top||s.top>I.bottom||s.right<I.left||s.left>I.right){e.style.display="none";return}}h=h.parentElement}e.style.display="flex";const g=s.left+(s.width||0)/2,y=s.top;e.style.left=`${g-e.offsetWidth/2}px`,e.style.top=`${y-e.offsetHeight-2}px`}function me(n,e){const{wrap:l,node:p,start:b,endNode:d,end:c}=n,i=document.createRange();i.setStart(p,b),i.setEnd(d,c);const s=i.toString().slice(e.sigLen);let h="";if(e.cipher==="PLAIN")try{h=A.decodeToString(s,e.base)}catch(g){console.error(g)}else{const g=prompt(`inØsight: enter password (${e.cipher}):`);if(!g)return;try{const y=A.decodeToNumberArray(s,e.base);e.cipher==="SPECK48_96CTR"?h=ue(y,ae(g)):e.cipher==="SPECK32_64ECB (insecure)"&&(h=pe(y,de(g)))}catch(y){console.error(y)}if(!h){alert("Decryption failed.");return}}if(h){i.deleteContents();const g=document.createElement("span");g.className="inzerosight-decoded",g.style.color="#00b4d8",g.style.fontWeight="600",g.textContent=` ${h} `,i.insertNode(g),l.remove(),C.delete(n)}}function we(n,e,l){let p=n,b=$(n.nodeValue,e,l);for(;b===p.nodeValue.length;){let d=p.nextSibling,c=!1;for(;(d==null?void 0:d.nodeType)===Node.ELEMENT_NODE&&d.tagName==="WBR";)c=!0,d=d.nextSibling;if(!c||(d==null?void 0:d.nodeType)!==Node.TEXT_NODE)break;const i=$(d.nodeValue,e,0);if(!i)break;p=d,b=i}return{endNode:p,end:b}}function v(n){if(!n||n.nodeType!==Node.TEXT_NODE)return;const e=n.nodeValue;if(!e||!e.includes(N))return;let l=0;for(;l<e.length;){const p=e.slice(l),b=be(p);if(!b)break;const d=l+b.sigIdx,{endNode:c,end:i}=we(n,b.base,d+b.sigLen);ge(n,b,d,c,i),l=c===n?i+1:e.length}}function J(n){if(!n)return;const e={SCRIPT:1,STYLE:1,TEXTAREA:1,INPUT:1,NOSCRIPT:1,"IN0-HOST":1},l=document.createTreeWalker(n,NodeFilter.SHOW_TEXT,{acceptNode:b=>{var d;return e[(d=b.parentElement)==null?void 0:d.tagName]?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}});let p;for(;p=l.nextNode();)v(p)}J(document.body);let F;function j(){F||C.size===0||(F=requestAnimationFrame(()=>{F=null,C.forEach(Y)}))}new MutationObserver(n=>{var e;for(const l of[...C])(!l.node.isConnected||!((e=l.node.nodeValue)!=null&&e.startsWith(N,l.start)))&&(l.wrap.remove(),C.delete(l));for(const l of n)if(l.type==="characterData")v(l.target);else for(const p of l.addedNodes)p.nodeType===Node.TEXT_NODE?v(p):p.nodeType===Node.ELEMENT_NODE&&p.id!=="in0-host"&&J(p);j()}).observe(document.documentElement,{childList:!0,subtree:!0,characterData:!0}),window.addEventListener("scroll",j,{capture:!0,passive:!0}),window.addEventListener("resize",j,{passive:!0})})();