Files
inzerosight/dist/firefox/content.js

56 lines
17 KiB
JavaScript
Raw Permalink 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 S={3:{unifier:"­",0:"",1:"",2:""},6:{unifier:"",0:"",1:"",2:"­",3:"",4:"",5:""},7:{unifier:"",0:"",1:"",2:"­",3:"",4:"",5:"",6:"\uFEFF"},encodeString:(e,t=7)=>Array.from(e,r=>(+t==7?ne(r):r.codePointAt(0)).toString(t).split("").map(u=>S[t][u]).join("")).join(S[t].unifier),encodeNumberArray:(e,t=7)=>e.map(r=>r.toString(t).split("").map(u=>S[t][u]).join("")).join(S[t].unifier),decodeToString:(e,t=7)=>S.decodeToNumberArray(e,t).map(r=>String.fromCodePoint(+t==7?re(r):r)).join(""),decodeToNumberArray:(e,t=7)=>e.split(S[t].unifier).map(r=>Array.from(r).map(u=>Object.keys(S[t]).find(h=>S[t][h]===u)).join("")).filter(Boolean).map(r=>parseInt(r,t))},ee="te aoinshrdlucmfwypvbgkjqxz.,!?'-:;()0123456789ETAOINSHRDLUCMFWYPVBGKJQXZ",M=[...new Set([...ee,...Array.from({length:95},(e,t)=>String.fromCharCode(t+32))])],te=new Map(M.map((e,t)=>[e,t])),ne=e=>te.get(e)??(e.codePointAt(0)<32?e.codePointAt(0)+95:e.codePointAt(0)),re=e=>e<95?M[e].codePointAt(0):e<127?e-95:e;function oe(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var D,G;function ie(){if(G)return D;G=1;function e(t={}){const r=t.bits||16,u=t.rounds||22,h=t.rightRotations||7,f=t.leftRotations||2,c=2**r,s=c-1,l=(a,o)=>a>>o|a<<r-o&s,g=(a,o)=>a<<o&s|a>>r-o,b=(a,o,n)=>(a=l(a,h),a=a+o&s,a^=n,o=g(o,f),o^=a,[a,o]),E=(a,o,n)=>(o^=a,o=l(o,f),a^=n,a=a-o&s,a=g(a,h),[a,o]);function k(a,o){let n=a[0],d=a[1],i=o[0],m=o.slice(1);[d,n]=b(d,n,i);for(let w=0;w<u-1;w++){const y=w%m.length;[m[y],i]=b(m[y],i,w),[d,n]=b(d,n,i)}return[n,d]}function A(a,o){let n=a[0],d=a[1],i=o[0],m=o.slice(1);for(let w=0;w<u-1;w++){const y=w%m.length;[m[y],i]=b(m[y],i,w)}for(let w=0;w<u;w++){const y=(u-2-w)%m.length;[d,n]=E(d,n,i),[m[y],i]=E(m[y],i,u-2-w)}return[n,d]}function p(a){return(o,n)=>{const d=a([o/c|0,o&s],n);return d[0]*c+d[1]}}return{encrypt:p(k),decrypt:p(A),encryptRaw:k,decryptRaw:A}}return D=e,D}var se=ie();const V=oe(se);var B,z;function W(){if(z)return B;z=1;const e="Input must be an string, Buffer or Uint8Array";function t(c){let s;if(c instanceof Uint8Array)s=c;else if(typeof c=="string")s=new TextEncoder().encode(c);else throw new Error(e);return s}function r(c){return Array.prototype.map.call(c,function(s){return(s<16?"0":"")+s.toString(16)}).join("")}function u(c){return(4294967296+c).toString(16).substring(1)}function h(c,s,l){let g=`
`+c+" = ";for(let b=0;b<s.length;b+=2){if(l===32)g+=u(s[b]).toUpperCase(),g+=" ",g+=u(s[b+1]).toUpperCase();else if(l===64)g+=u(s[b+1]).toUpperCase(),g+=u(s[b]).toUpperCase();else throw new Error("Invalid size "+l);b%6===4?g+=`
`+new Array(c.length+4).join(" "):b<s.length-2&&(g+=" ")}console.log(g)}function f(c,s,l){let g=new Date().getTime();const b=new Uint8Array(s);for(let k=0;k<s;k++)b[k]=k%256;const E=new Date().getTime();console.log("Generated random input in "+(E-g)+"ms"),g=E;for(let k=0;k<l;k++){const A=c(b),p=new Date().getTime(),a=p-g;g=p,console.log("Hashed in "+a+"ms: "+A.substring(0,20)+"..."),console.log(Math.round(s/(1<<20)/(a/1e3)*100)/100+" MB PER SECOND")}}return B={normalizeInput:t,toHex:r,debugPrint:h,testSpeed:f},B}var v,q;function le(){if(q)return v;q=1;const e=W();function t(n,d,i){const m=n[d]+n[i];let w=n[d+1]+n[i+1];m>=4294967296&&w++,n[d]=m,n[d+1]=w}function r(n,d,i,m){let w=n[d]+i;i<0&&(w+=4294967296);let y=n[d+1]+m;w>=4294967296&&y++,n[d]=w,n[d+1]=y}function u(n,d){return n[d]^n[d+1]<<8^n[d+2]<<16^n[d+3]<<24}function h(n,d,i,m,w,y){const Ie=g[w],Te=g[w+1],xe=g[y],Ce=g[y+1];t(l,n,d),r(l,n,Ie,Te);let I=l[m]^l[n],T=l[m+1]^l[n+1];l[m]=T,l[m+1]=I,t(l,i,m),I=l[d]^l[i],T=l[d+1]^l[i+1],l[d]=I>>>24^T<<8,l[d+1]=T>>>24^I<<8,t(l,n,d),r(l,n,xe,Ce),I=l[m]^l[n],T=l[m+1]^l[n+1],l[m]=I>>>16^T<<16,l[m+1]=T>>>16^I<<16,t(l,i,m),I=l[d]^l[i],T=l[d+1]^l[i+1],l[d]=T>>>31^I<<1,l[d+1]=I>>>31^T<<1}const f=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],s=new Uint8Array(c.map(function(n){return n*2})),l=new Uint32Array(32),g=new Uint32Array(32);function b(n,d){let i=0;for(i=0;i<16;i++)l[i]=n.h[i],l[i+16]=f[i];for(l[24]=l[24]^n.t,l[25]=l[25]^n.t/4294967296,d&&(l[28]=~l[28],l[29]=~l[29]),i=0;i<32;i++)g[i]=u(n.b,4*i);for(i=0;i<12;i++)h(0,8,16,24,s[i*16+0],s[i*16+1]),h(2,10,18,26,s[i*16+2],s[i*16+3]),h(4,12,20,28,s[i*16+4],s[i*16+5]),h(6,14,22,30,s[i*16+6],s[i*16+7]),h(0,10,20,30,s[i*16+8],s[i*16+9]),h(2,12,22,24,s[i*16+10],s[i*16+11]),h(4,14,16,26,s[i*16+12],s[i*16+13]),h(6,8,18,28,s[i*16+14],s[i*16+15]);for(i=0;i<16;i++)n.h[i]=n.h[i]^l[i]^l[i+16]}const E=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(n,d,i,m){if(n===0||n>64)throw new Error("Illegal output length, expected 0 < length <= 64");if(d&&d.length>64)throw new Error("Illegal key, expected Uint8Array with 0 < length <= 64");if(i&&i.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:n};E.fill(0),E[0]=n,d&&(E[1]=d.length),E[2]=1,E[3]=1,i&&E.set(i,32),m&&E.set(m,48);for(let y=0;y<16;y++)w.h[y]=f[y]^u(E,y*4);return d&&(A(w,d),w.c=128),w}function A(n,d){for(let i=0;i<d.length;i++)n.c===128&&(n.t+=n.c,b(n,!1),n.c=0),n.b[n.c++]=d[i]}function p(n){for(n.t+=n.c;n.c<128;)n.b[n.c++]=0;b(n,!0);const d=new Uint8Array(n.outlen);for(let i=0;i<n.outlen;i++)d[i]=n.h[i>>2]>>8*(i&3);return d}function a(n,d,i,m,w){i=i||64,n=e.normalizeInput(n),m&&(m=e.normalizeInput(m)),w&&(w=e.normalizeInput(w));const y=k(i,d,m,w);return A(y,n),p(y)}function o(n,d,i,m,w){const y=a(n,d,i,m,w);return e.toHex(y)}return v={blake2b:a,blake2bHex:o,blake2bInit:k,blake2bUpdate:A,blake2bFinal:p},v}var O,X;function ce(){if(X)return O;X=1;const e=W();function t(p,a){return p[a]^p[a+1]<<8^p[a+2]<<16^p[a+3]<<24}function r(p,a,o,n,d,i){c[p]=c[p]+c[a]+d,c[n]=u(c[n]^c[p],16),c[o]=c[o]+c[n],c[a]=u(c[a]^c[o],12),c[p]=c[p]+c[a]+i,c[n]=u(c[n]^c[p],8),c[o]=c[o]+c[n],c[a]=u(c[a]^c[o],7)}function u(p,a){return p>>>a^p<<32-a}const h=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),f=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),s=new Uint32Array(16);function l(p,a){let o=0;for(o=0;o<8;o++)c[o]=p.h[o],c[o+8]=h[o];for(c[12]^=p.t,c[13]^=p.t/4294967296,a&&(c[14]=~c[14]),o=0;o<16;o++)s[o]=t(p.b,4*o);for(o=0;o<10;o++)r(0,4,8,12,s[f[o*16+0]],s[f[o*16+1]]),r(1,5,9,13,s[f[o*16+2]],s[f[o*16+3]]),r(2,6,10,14,s[f[o*16+4]],s[f[o*16+5]]),r(3,7,11,15,s[f[o*16+6]],s[f[o*16+7]]),r(0,5,10,15,s[f[o*16+8]],s[f[o*16+9]]),r(1,6,11,12,s[f[o*16+10]],s[f[o*16+11]]),r(2,7,8,13,s[f[o*16+12]],s[f[o*16+13]]),r(3,4,9,14,s[f[o*16+14]],s[f[o*16+15]]);for(o=0;o<8;o++)p.h[o]^=c[o]^c[o+8]}function g(p,a){if(!(p>0&&p<=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 n={h:new Uint32Array(h),b:new Uint8Array(64),c:0,t:0,outlen:p};return n.h[0]^=16842752^o<<8^p,o>0&&(b(n,a),n.c=64),n}function b(p,a){for(let o=0;o<a.length;o++)p.c===64&&(p.t+=p.c,l(p,!1),p.c=0),p.b[p.c++]=a[o]}function E(p){for(p.t+=p.c;p.c<64;)p.b[p.c++]=0;l(p,!0);const a=new Uint8Array(p.outlen);for(let o=0;o<p.outlen;o++)a[o]=p.h[o>>2]>>8*(o&3)&255;return a}function k(p,a,o){o=o||32,p=e.normalizeInput(p);const n=g(o,a);return b(n,p),E(n)}function A(p,a,o){const n=k(p,a,o);return e.toHex(n)}return O={blake2s:k,blake2sHex:A,blake2sInit:g,blake2sUpdate:b,blake2sFinal:E},O}var _,K;function ae(){if(K)return _;K=1;const e=le(),t=ce();return _={blake2b:e.blake2b,blake2bHex:e.blake2bHex,blake2bInit:e.blake2bInit,blake2bUpdate:e.blake2bUpdate,blake2bFinal:e.blake2bFinal,blake2s:t.blake2s,blake2sHex:t.blake2sHex,blake2sInit:t.blake2sInit,blake2sUpdate:t.blake2sUpdate,blake2sFinal:t.blake2sFinal},_}var $=ae();const ue=V({bits:24,rounds:23,rightRotations:8,leftRotations:3});function fe(e){const t=$.blake2bHex(e,null,12);return[parseInt(t.slice(0,6),16),parseInt(t.slice(6,12),16),parseInt(t.slice(12,18),16),parseInt(t.slice(18,24),16)]}function de(e,t){if(!e||e.length===0)return"";const r=e[0];return e.slice(1).map((h,f)=>{const c=r*16777216+(f&16777215),s=ue.encrypt(c,t),l=(h^s)>>>0;try{return String.fromCodePoint(l)}catch{return""}}).join("")}const pe=V();function he(e){const t=$.blake2bHex(e,null,8);return[parseInt(t.slice(0,4),16),parseInt(t.slice(4,8),16),parseInt(t.slice(8,12),16),parseInt(t.slice(12,16),16)]}function ge(e,t){return e.map(r=>{try{return String.fromCodePoint(pe.decrypt(r,t))}catch{return""}}).join("")}const C="­",P={3:"­",6:"­",7:"­"},F={0:"PLAIN",1:"SPECK48_96CTR",2:"SPECK32_64ECB (insecure)"};Object.fromEntries(Object.entries(F).map(([e,t])=>[t,+e]));const be=Object.entries(P).flatMap(([e,t])=>Object.entries(F).map(([r,u])=>{const h=(+r).toString(e).padStart(4,"0");if(h.length!==4)throw new RangeError(`Cipher ID ${r} exceeds ZWUS-${e}'s signature capacity`);const f=t+S[e].unifier+S[e][0]+Array.from(h,c=>S[e][c]).join("");if(f.length!==11)throw new RangeError("Signatures must contain exactly 11 characters");return{base:e,cipher:u,sig:f,legacy:!1}}));function Y(e,t){let r=e.indexOf(C);for(;r!==-1;){const u=t.find(h=>e.startsWith(h.sig,r)&&(!h.legacyPlain||e[r+h.sig.length]!==S[h.base].unifier));if(u){const{base:h,cipher:f,sig:c,legacy:s}=u;return{base:h,cipher:f,payload:e.slice(r+c.length),sigIdx:r,sigLen:c.length,legacy:s}}r=e.indexOf(C,r+1)}return null}const me=e=>Y(e,be),we=[3,6,7].flatMap(e=>[...[1,2].map(t=>({base:String(e),cipher:F[t],legacy:!0,sig:P[e]+S[e].unifier+S[e][0].repeat(3)+S[e][t]})),{base:String(e),cipher:"PLAIN",sig:P[e],legacy:!0,legacyPlain:!0}]),ye=e=>Y(e,we);function Ee(e){const t=me(e),r=ye(e);return!t||r&&r.sigIdx<t.sigIdx&&J(e,r.base,r.sigIdx+r.sigLen)<t.sigIdx?r:t}function J(e,t,r){const u=new Set(Object.values(S[t]));let h=r;for(;h<e.length&&u.has(e[h]);)h++;return h}let N,j;const x=new Set;function ke(){if(N)return;N=document.createElement("div"),N.id="in0-host",j=N.attachShadow({mode:"open"});const e=document.createElement("style");e.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;
}
`,j.appendChild(e),(document.body||document.documentElement).appendChild(N)}function Se(e,t,r,u,h){for(const b of x)if(b.node===e&&b.start===r)return;ke();const f=document.createElement("div");f.className="in0-wrap";const c=document.createElement("button");c.className="in0-btn",c.textContent=t.cipher==="PLAIN"?"Decode":"Decrypt";const s=document.createElement("span");s.className="in0-badge",s.textContent="Ø",c.appendChild(s);const l=document.createElement("div");l.className="in0-arrow",f.appendChild(c),f.appendChild(l),j.appendChild(f);const g={wrap:f,node:e,start:r,endNode:u,end:h};x.add(g),c.onclick=()=>Ae(g,t),Z(g)}function Z(e){const{wrap:t,node:r,start:u,endNode:h,end:f}=e;if(!r.isConnected||!h.isConnected){t.remove(),x.delete(e);return}const c=r.parentElement;if(!c||c.checkVisibility&&!c.checkVisibility({checkOpacity:!0,checkVisibilityCSS:!0})){t.style.display="none";return}const s=document.createRange();try{s.setStart(r,u),s.setEnd(h,Math.min(f,h.nodeValue.length))}catch{t.remove(),x.delete(e);return}let l=s.getBoundingClientRect();if(!l.width&&!l.height&&(l=c.getBoundingClientRect()),!l.width&&!l.height){t.style.display="none";return}if(l.bottom<0||l.top>window.innerHeight||l.right<0||l.left>window.innerWidth){t.style.display="none";return}let g=c;for(;g&&g!==document.body&&g!==document.documentElement;){const k=window.getComputedStyle(g);if(k.overflow!=="visible"||k.overflowX!=="visible"||k.overflowY!=="visible"){const A=g.getBoundingClientRect();if(l.bottom<A.top||l.top>A.bottom||l.right<A.left||l.left>A.right){t.style.display="none";return}}g=g.parentElement}t.style.display="flex";const b=l.left+(l.width||0)/2,E=l.top;t.style.left=`${b-t.offsetWidth/2}px`,t.style.top=`${E-t.offsetHeight-2}px`}function Ae(e,t){const{wrap:r,node:u,start:h,endNode:f,end:c}=e,s=document.createRange();s.setStart(u,h),s.setEnd(f,c);const l=s.toString().slice(t.sigLen);let g="";if(t.cipher==="PLAIN")try{g=S.decodeToString(l,t.base)}catch(b){console.error(b)}else{const b=prompt(`inØsight: enter password (${t.cipher}):`);if(!b)return;try{const E=S.decodeToNumberArray(l,t.base);t.cipher==="SPECK48_96CTR"?g=de(E,fe(b)):t.cipher==="SPECK32_64ECB (insecure)"&&(g=ge(E,he(b)))}catch(E){console.error(E)}if(!g){alert("Decryption failed.");return}}if(g){s.deleteContents();const b=document.createElement("span");b.className="inzerosight-decoded",b.style.color="#00b4d8",b.style.fontWeight="600",b.textContent=` ${g} `,s.insertNode(b),r.remove(),x.delete(e)}}function U(e,t){let r=e[t],u=!1;for(;(r==null?void 0:r.nodeType)===Node.ELEMENT_NODE&&r.tagName==="WBR";)u=!0,r=r[t];return u&&(r==null?void 0:r.nodeType)===Node.TEXT_NODE?r:null}function R(e){if(!e||e.nodeType!==Node.TEXT_NODE)return;for(let f;f=U(e,"previousSibling");)e=f;const t=[e];let r=e.nodeValue;for(let f;f=U(t.at(-1),"nextSibling");)t.push(f),r+=f.nodeValue;if(!r||!r.includes(C))return;const u=(f,c)=>{for(const s of t){if(f<s.nodeValue.length||c&&f===s.nodeValue.length)return{node:s,offset:f};f-=s.nodeValue.length}return{node:t.at(-1),offset:t.at(-1).nodeValue.length}};let h=0;for(;h<r.length;){const f=Ee(r.slice(h));if(!f)break;const c=h+f.sigIdx,s=J(r,f.base,c+f.sigLen),l=u(c,!1),g=u(s,!0);Se(l.node,f,l.offset,g.node,g.offset),h=s+1}}function Q(e){if(!e)return;const t={SCRIPT:1,STYLE:1,TEXTAREA:1,INPUT:1,NOSCRIPT:1,"IN0-HOST":1},r=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,{acceptNode:h=>{var f;return t[(f=h.parentElement)==null?void 0:f.tagName]?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}});let u;for(;u=r.nextNode();)U(u,"previousSibling")||R(u)}Q(document.body);let H;function L(){H||x.size===0||(H=requestAnimationFrame(()=>{H=null,x.forEach(Z)}))}new MutationObserver(e=>{var t;for(const r of[...x]){let u=((t=r.node.nodeValue)==null?void 0:t.slice(r.start))||"";for(let h=r.node;u.length<C.length&&(h=U(h,"nextSibling"));)u+=h.nodeValue;(!r.node.isConnected||!u.startsWith(C))&&(r.wrap.remove(),x.delete(r))}for(const r of e)if(r.type==="characterData")R(r.target);else for(const u of r.addedNodes)u.nodeType===Node.TEXT_NODE?R(u):u.nodeType===Node.ELEMENT_NODE&&u.tagName==="WBR"?(R(u.previousSibling),R(u.nextSibling)):u.nodeType===Node.ELEMENT_NODE&&u.id!=="in0-host"&&Q(u);L()}).observe(document.documentElement,{childList:!0,subtree:!0,characterData:!0}),window.addEventListener("scroll",L,{capture:!0,passive:!0}),window.addEventListener("resize",L,{passive:!0})})();