From 248b39bd1bed6503ff00d716f4e2dfa677b071b3 Mon Sep 17 00:00:00 2001 From: multipleof4 Date: Sat, 12 Sep 2026 18:06:20 -0700 Subject: [PATCH] fix(content): use fixed positioning, capture scroll, and container clipping --- content.js | 67 ++++++++++++++++++++++++++++++++++------- dist/chrome/content.js | 11 ++++--- dist/firefox/content.js | 11 ++++--- dist/web/index.html | 62 +++++++++++++++++++------------------- 4 files changed, 99 insertions(+), 52 deletions(-) diff --git a/content.js b/content.js index 0104364..08d69cb 100644 --- a/content.js +++ b/content.js @@ -14,13 +14,14 @@ function initShadow() { const s = document.createElement('style'); s.textContent = ` .in0-wrap { - position: absolute; + 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; @@ -69,6 +70,7 @@ function initShadow() { } function createOverlay(node, parsed, start, end) { + for (const e of active) if (e.node === node && e.start === start) return; initShadow(); const wrap = document.createElement('div'); wrap.className = 'in0-wrap'; @@ -103,6 +105,12 @@ function updatePos(entry) { active.delete(entry); return; } + const p = node.parentElement; + if (!p || (p.checkVisibility && !p.checkVisibility({ checkOpacity: true, checkVisibilityCSS: true }))) { + wrap.style.display = 'none'; + return; + } + const r = document.createRange(); try { r.setStart(node, start); @@ -113,11 +121,35 @@ function updatePos(entry) { return; } let rect = r.getBoundingClientRect(); - if (!rect.width && !rect.height && node.parentElement) { - rect = node.parentElement.getBoundingClientRect(); + if (!rect.width && !rect.height) rect = p.getBoundingClientRect(); + if (!rect.width && !rect.height) { + wrap.style.display = 'none'; + return; } - const x = rect.left + window.scrollX + (rect.width || 0) / 2; - const y = rect.top + window.scrollY; + + // Check viewport bounds + if (rect.bottom < 0 || rect.top > window.innerHeight || rect.right < 0 || rect.left > window.innerWidth) { + wrap.style.display = 'none'; + return; + } + + // Check ancestor scroll/overflow clipping + let cur = p; + while (cur && cur !== document.body && cur !== document.documentElement) { + const s = window.getComputedStyle(cur); + if (s.overflow !== 'visible' || s.overflowX !== 'visible' || s.overflowY !== 'visible') { + const cr = cur.getBoundingClientRect(); + if (rect.bottom < cr.top || rect.top > cr.bottom || rect.right < cr.left || rect.left > cr.right) { + wrap.style.display = 'none'; + return; + } + } + cur = cur.parentElement; + } + + wrap.style.display = 'flex'; + const x = rect.left + (rect.width || 0) / 2; + const y = rect.top; wrap.style.left = `${x - wrap.offsetWidth / 2}px`; wrap.style.top = `${y - wrap.offsetHeight - 2}px`; } @@ -167,14 +199,11 @@ function onAction(entry, parsed) { } } -const scanned = new WeakSet(); - function scanNode(node) { - if (!node || node.nodeType !== Node.TEXT_NODE || scanned.has(node)) return; + if (!node || node.nodeType !== Node.TEXT_NODE) return; const val = node.nodeValue; if (!val || !val.includes(SIG_PREFIX)) return; - scanned.add(node); let idx = 0; while (idx < val.length) { const sub = val.slice(idx); @@ -199,7 +228,22 @@ function scanTree(root) { scanTree(document.body); +let rafId; +function scheduleUpdate() { + if (rafId || active.size === 0) return; + rafId = requestAnimationFrame(() => { + rafId = null; + active.forEach(updatePos); + }); +} + const obs = new MutationObserver(muts => { + for (const e of [...active]) { + if (!e.node.isConnected || !e.node.nodeValue?.includes(SIG_PREFIX)) { + e.wrap.remove(); + active.delete(e); + } + } for (const m of muts) { if (m.type === 'characterData') scanNode(m.target); else for (const an of m.addedNodes) { @@ -207,9 +251,10 @@ const obs = new MutationObserver(muts => { else if (an.nodeType === Node.ELEMENT_NODE && an.id !== 'in0-host') scanTree(an); } } + scheduleUpdate(); }); obs.observe(document.documentElement, { childList: true, subtree: true, characterData: true }); -window.addEventListener('scroll', () => active.forEach(updatePos), { passive: true }); -window.addEventListener('resize', () => active.forEach(updatePos), { passive: true }); +window.addEventListener('scroll', scheduleUpdate, { capture: true, passive: true }); +window.addEventListener('resize', scheduleUpdate, { passive: true }); diff --git a/dist/chrome/content.js b/dist/chrome/content.js index 869442e..096fbc0 100644 --- a/dist/chrome/content.js +++ b/dist/chrome/content.js @@ -1,14 +1,15 @@ -(function(){"use strict";const y={3:{unifier:"­",0:"᠎",1:"​",2:"‍"},6:{unifier:"‌",0:"‍",1:"‏",2:"­",3:"⁠",4:"​",5:"‎"},8:{unifier:"‌",0:"‍",1:"‏",2:"­",3:"⁠",4:"​",5:"‎",6:"᠎",7:"\uFEFF"},encodeString:(o,e=3)=>Array.from(o,l=>l.codePointAt(0).toString(e).split("").map(b=>y[e][b]).join("")).join(y[e].unifier),encodeNumberArray:(o,e=3)=>o.map(l=>l.toString(e).split("").map(b=>y[e][b]).join("")).join(y[e].unifier),decodeToString:(o,e=3)=>o.split(y[e].unifier).map(l=>String.fromCodePoint(parseInt(Array.from(l).map(b=>Object.keys(y[e]).find(d=>y[e][d]===b)).join(""),e))).join(""),decodeToNumberArray:(o,e=3)=>o.split(y[e].unifier).map(l=>parseInt(Array.from(l).map(b=>Object.keys(y[e]).find(d=>y[e][d]===b)).join(""),e))};function V(o){return o&&o.__esModule&&Object.prototype.hasOwnProperty.call(o,"default")?o.default:o}var D,P;function Y(){if(P)return D;P=1;function o(e={}){const l=e.bits||16,b=e.rounds||22,d=e.rightRotations||7,p=e.leftRotations||2,c=2**l,s=c-1,i=(a,n)=>a>>n|a<a<>l-n,m=(a,n,t)=>(a=i(a,d),a=a+n&s,a^=t,n=h(n,p),n^=a,[a,n]),E=(a,n,t)=>(n^=a,n=i(n,p),a^=t,a=a-n&s,a=h(a,d),[a,n]);function I(a,n){let t=a[0],u=a[1],r=n[0],g=n.slice(1);[u,t]=m(u,t,r);for(let w=0;w{const u=a([n/c|0,n&s],t);return u[0]*c+u[1]}}return{encrypt:f(I),decrypt:f(A),encryptRaw:I,decryptRaw:A}}return D=o,D}var J=Y();const v=V(J);var U,H;function L(){if(H)return U;H=1;const o="Input must be an string, Buffer or Uint8Array";function e(c){let s;if(c instanceof Uint8Array)s=c;else if(typeof c=="string")s=new TextEncoder().encode(c);else throw new Error(o);return s}function l(c){return Array.prototype.map.call(c,function(s){return(s<16?"0":"")+s.toString(16)}).join("")}function b(c){return(4294967296+c).toString(16).substring(1)}function d(c,s,i){let h=` -`+c+" = ";for(let m=0;m=4294967296&&w++,t[u]=g,t[u+1]=w}function l(t,u,r,g){let w=t[u]+r;r<0&&(w+=4294967296);let k=t[u+1]+g;w>=4294967296&&k++,t[u]=w,t[u+1]=k}function b(t,u){return t[u]^t[u+1]<<8^t[u+2]<<16^t[u+3]<<24}function d(t,u,r,g,w,k){const de=h[w],pe=h[w+1],be=h[k],he=h[k+1];e(i,t,u),l(i,t,de,pe);let S=i[g]^i[t],T=i[g+1]^i[t+1];i[g]=T,i[g+1]=S,e(i,r,g),S=i[u]^i[r],T=i[u+1]^i[r+1],i[u]=S>>>24^T<<8,i[u+1]=T>>>24^S<<8,e(i,t,u),l(i,t,be,he),S=i[g]^i[t],T=i[g+1]^i[t+1],i[g]=S>>>16^T<<16,i[g+1]=T>>>16^S<<16,e(i,r,g),S=i[u]^i[r],T=i[u+1]^i[r+1],i[u]=T>>>31^S<<1,i[u+1]=S>>>31^T<<1}const p=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(t){return t*2})),i=new Uint32Array(32),h=new Uint32Array(32);function m(t,u){let r=0;for(r=0;r<16;r++)i[r]=t.h[r],i[r+16]=p[r];for(i[24]=i[24]^t.t,i[25]=i[25]^t.t/4294967296,u&&(i[28]=~i[28],i[29]=~i[29]),r=0;r<32;r++)h[r]=b(t.b,4*r);for(r=0;r<12;r++)d(0,8,16,24,s[r*16+0],s[r*16+1]),d(2,10,18,26,s[r*16+2],s[r*16+3]),d(4,12,20,28,s[r*16+4],s[r*16+5]),d(6,14,22,30,s[r*16+6],s[r*16+7]),d(0,10,20,30,s[r*16+8],s[r*16+9]),d(2,12,22,24,s[r*16+10],s[r*16+11]),d(4,14,16,26,s[r*16+12],s[r*16+13]),d(6,8,18,28,s[r*16+14],s[r*16+15]);for(r=0;r<16;r++)t.h[r]=t.h[r]^i[r]^i[r+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 I(t,u,r,g){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(g&&g.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};E.fill(0),E[0]=t,u&&(E[1]=u.length),E[2]=1,E[3]=1,r&&E.set(r,32),g&&E.set(g,48);for(let k=0;k<16;k++)w.h[k]=p[k]^b(E,k*4);return u&&(A(w,u),w.c=128),w}function A(t,u){for(let r=0;r>2]>>8*(r&3);return u}function a(t,u,r,g,w){r=r||64,t=o.normalizeInput(t),g&&(g=o.normalizeInput(g)),w&&(w=o.normalizeInput(w));const k=I(r,u,g,w);return A(k,t),f(k)}function n(t,u,r,g,w){const k=a(t,u,r,g,w);return o.toHex(k)}return B={blake2b:a,blake2bHex:n,blake2bInit:I,blake2bUpdate:A,blake2bFinal:f},B}var N,z;function Z(){if(z)return N;z=1;const o=L();function e(f,a){return f[a]^f[a+1]<<8^f[a+2]<<16^f[a+3]<<24}function l(f,a,n,t,u,r){c[f]=c[f]+c[a]+u,c[t]=b(c[t]^c[f],16),c[n]=c[n]+c[t],c[a]=b(c[a]^c[n],12),c[f]=c[f]+c[a]+r,c[t]=b(c[t]^c[f],8),c[n]=c[n]+c[t],c[a]=b(c[a]^c[n],7)}function b(f,a){return f>>>a^f<<32-a}const d=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),p=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 i(f,a){let n=0;for(n=0;n<8;n++)c[n]=f.h[n],c[n+8]=d[n];for(c[12]^=f.t,c[13]^=f.t/4294967296,a&&(c[14]=~c[14]),n=0;n<16;n++)s[n]=e(f.b,4*n);for(n=0;n<10;n++)l(0,4,8,12,s[p[n*16+0]],s[p[n*16+1]]),l(1,5,9,13,s[p[n*16+2]],s[p[n*16+3]]),l(2,6,10,14,s[p[n*16+4]],s[p[n*16+5]]),l(3,7,11,15,s[p[n*16+6]],s[p[n*16+7]]),l(0,5,10,15,s[p[n*16+8]],s[p[n*16+9]]),l(1,6,11,12,s[p[n*16+10]],s[p[n*16+11]]),l(2,7,8,13,s[p[n*16+12]],s[p[n*16+13]]),l(3,4,9,14,s[p[n*16+14]],s[p[n*16+15]]);for(n=0;n<8;n++)f.h[n]^=c[n]^c[n+8]}function h(f,a){if(!(f>0&&f<=32))throw new Error("Incorrect output length, should be in [1, 32]");const n=a?a.length:0;if(a&&!(n>0&&n<=32))throw new Error("Incorrect key length, should be in [1, 32]");const t={h:new Uint32Array(d),b:new Uint8Array(64),c:0,t:0,outlen:f};return t.h[0]^=16842752^n<<8^f,n>0&&(m(t,a),t.c=64),t}function m(f,a){for(let n=0;n>2]>>8*(n&3)&255;return a}function I(f,a,n){n=n||32,f=o.normalizeInput(f);const t=h(n,a);return m(t,f),E(t)}function A(f,a,n){const t=I(f,a,n);return o.toHex(t)}return N={blake2s:I,blake2sHex:A,blake2sInit:h,blake2sUpdate:m,blake2sFinal:E},N}var _,G;function ee(){if(G)return _;G=1;const o=Q(),e=Z();return _={blake2b:o.blake2b,blake2bHex:o.blake2bHex,blake2bInit:o.blake2bInit,blake2bUpdate:o.blake2bUpdate,blake2bFinal:o.blake2bFinal,blake2s:e.blake2s,blake2sHex:e.blake2sHex,blake2sInit:e.blake2sInit,blake2sUpdate:e.blake2sUpdate,blake2sFinal:e.blake2sFinal},_}var q=ee();const te=v({bits:24,rounds:23,rightRotations:8,leftRotations:3});function ne(o){const e=q.blake2bHex(o,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 re(o,e){if(!o||o.length===0)return"";const l=o[0];return o.slice(1).map((d,p)=>{const c=l*16777216+(p&16777215),s=te.encrypt(c,e),i=(d^s)>>>0;try{return String.fromCodePoint(i)}catch{return""}}).join("")}const oe=v();function ie(o){const e=q.blake2bHex(o,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 se(o,e){return o.map(l=>{try{return String.fromCodePoint(oe.decrypt(l,e))}catch{return""}}).join("")}const K="‍​­",C={3:"‍​­᠎‍",6:"‍​­‌‍",8:"‍​­‌‌"},X={1:"SPECK48_96CTR",2:"SPECK32_64ECB (insecure)"};Object.fromEntries(Object.entries(X).map(([o,e])=>[e,+o]));function ce(o){if(!o.includes(K))return null;const e=Object.keys(C).find(p=>o.includes(C[p]));if(!e)return null;const l=o.indexOf(C[e]),b=o.slice(l+C[e].length),d=y[e].unifier+y[e][0];if(b.startsWith(d)){const c=Array.from(b.slice(d.length,d.length+3)).map(m=>Object.keys(y[e]).find(E=>y[e][E]===m)).join(""),s=X[parseInt(c,e)],i=b.slice(d.length+3),h=C[e].length+d.length+3;return{base:e,cipher:s,payload:i,sigIdx:l,sigLen:h}}return{base:e,cipher:"PLAIN",payload:b,sigIdx:l,sigLen:C[e].length}}function ae(o,e,l){const b=new Set(Object.values(y[e]));let d=l;for(;dArray.from(s,a=>a.codePointAt(0).toString(e).split("").map(d=>I[e][d]).join("")).join(I[e].unifier),encodeNumberArray:(s,e=3)=>s.map(a=>a.toString(e).split("").map(d=>I[e][d]).join("")).join(I[e].unifier),decodeToString:(s,e=3)=>s.split(I[e].unifier).map(a=>String.fromCodePoint(parseInt(Array.from(a).map(d=>Object.keys(I[e]).find(p=>I[e][p]===d)).join(""),e))).join(""),decodeToNumberArray:(s,e=3)=>s.split(I[e].unifier).map(a=>parseInt(Array.from(a).map(d=>Object.keys(I[e]).find(p=>I[e][p]===d)).join(""),e))};function Y(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var U,H;function J(){if(H)return U;H=1;function s(e={}){const a=e.bits||16,d=e.rounds||22,p=e.rightRotations||7,b=e.leftRotations||2,c=2**a,r=c-1,i=(l,n)=>l>>n|l<l<>a-n,w=(l,n,t)=>(l=i(l,p),l=l+n&r,l^=t,n=h(n,b),n^=l,[l,n]),k=(l,n,t)=>(n^=l,n=i(n,b),l^=t,l=l-n&r,l=h(l,p),[l,n]);function E(l,n){let t=l[0],u=l[1],o=n[0],g=n.slice(1);[u,t]=w(u,t,o);for(let m=0;m{const u=l([n/c|0,n&r],t);return u[0]*c+u[1]}}return{encrypt:f(E),decrypt:f(A),encryptRaw:E,decryptRaw:A}}return U=s,U}var Q=J();const L=Y(Q);var D,z;function M(){if(z)return D;z=1;const s="Input must be an string, Buffer or Uint8Array";function e(c){let r;if(c instanceof Uint8Array)r=c;else if(typeof c=="string")r=new TextEncoder().encode(c);else throw new Error(s);return r}function a(c){return Array.prototype.map.call(c,function(r){return(r<16?"0":"")+r.toString(16)}).join("")}function d(c){return(4294967296+c).toString(16).substring(1)}function p(c,r,i){let h=` +`+c+" = ";for(let w=0;w=4294967296&&m++,t[u]=g,t[u+1]=m}function a(t,u,o,g){let m=t[u]+o;o<0&&(m+=4294967296);let y=t[u+1]+g;m>=4294967296&&y++,t[u]=m,t[u+1]=y}function d(t,u){return t[u]^t[u+1]<<8^t[u+2]<<16^t[u+3]<<24}function p(t,u,o,g,m,y){const pe=h[m],be=h[m+1],he=h[y],ge=h[y+1];e(i,t,u),a(i,t,pe,be);let C=i[g]^i[t],S=i[g+1]^i[t+1];i[g]=S,i[g+1]=C,e(i,o,g),C=i[u]^i[o],S=i[u+1]^i[o+1],i[u]=C>>>24^S<<8,i[u+1]=S>>>24^C<<8,e(i,t,u),a(i,t,he,ge),C=i[g]^i[t],S=i[g+1]^i[t+1],i[g]=C>>>16^S<<16,i[g+1]=S>>>16^C<<16,e(i,o,g),C=i[u]^i[o],S=i[u+1]^i[o+1],i[u]=S>>>31^C<<1,i[u+1]=C>>>31^S<<1}const b=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],r=new Uint8Array(c.map(function(t){return t*2})),i=new Uint32Array(32),h=new Uint32Array(32);function w(t,u){let o=0;for(o=0;o<16;o++)i[o]=t.h[o],i[o+16]=b[o];for(i[24]=i[24]^t.t,i[25]=i[25]^t.t/4294967296,u&&(i[28]=~i[28],i[29]=~i[29]),o=0;o<32;o++)h[o]=d(t.b,4*o);for(o=0;o<12;o++)p(0,8,16,24,r[o*16+0],r[o*16+1]),p(2,10,18,26,r[o*16+2],r[o*16+3]),p(4,12,20,28,r[o*16+4],r[o*16+5]),p(6,14,22,30,r[o*16+6],r[o*16+7]),p(0,10,20,30,r[o*16+8],r[o*16+9]),p(2,12,22,24,r[o*16+10],r[o*16+11]),p(4,14,16,26,r[o*16+12],r[o*16+13]),p(6,8,18,28,r[o*16+14],r[o*16+15]);for(o=0;o<16;o++)t.h[o]=t.h[o]^i[o]^i[o+16]}const k=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 E(t,u,o,g){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(o&&o.length!==16)throw new Error("Illegal salt, expected Uint8Array with length is 16");if(g&&g.length!==16)throw new Error("Illegal personal, expected Uint8Array with length is 16");const m={b:new Uint8Array(128),h:new Uint32Array(16),t:0,c:0,outlen:t};k.fill(0),k[0]=t,u&&(k[1]=u.length),k[2]=1,k[3]=1,o&&k.set(o,32),g&&k.set(g,48);for(let y=0;y<16;y++)m.h[y]=b[y]^d(k,y*4);return u&&(A(m,u),m.c=128),m}function A(t,u){for(let o=0;o>2]>>8*(o&3);return u}function l(t,u,o,g,m){o=o||64,t=s.normalizeInput(t),g&&(g=s.normalizeInput(g)),m&&(m=s.normalizeInput(m));const y=E(o,u,g,m);return A(y,t),f(y)}function n(t,u,o,g,m){const y=l(t,u,o,g,m);return s.toHex(y)}return B={blake2b:l,blake2bHex:n,blake2bInit:E,blake2bUpdate:A,blake2bFinal:f},B}var N,q;function ee(){if(q)return N;q=1;const s=M();function e(f,l){return f[l]^f[l+1]<<8^f[l+2]<<16^f[l+3]<<24}function a(f,l,n,t,u,o){c[f]=c[f]+c[l]+u,c[t]=d(c[t]^c[f],16),c[n]=c[n]+c[t],c[l]=d(c[l]^c[n],12),c[f]=c[f]+c[l]+o,c[t]=d(c[t]^c[f],8),c[n]=c[n]+c[t],c[l]=d(c[l]^c[n],7)}function d(f,l){return f>>>l^f<<32-l}const p=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),b=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),r=new Uint32Array(16);function i(f,l){let n=0;for(n=0;n<8;n++)c[n]=f.h[n],c[n+8]=p[n];for(c[12]^=f.t,c[13]^=f.t/4294967296,l&&(c[14]=~c[14]),n=0;n<16;n++)r[n]=e(f.b,4*n);for(n=0;n<10;n++)a(0,4,8,12,r[b[n*16+0]],r[b[n*16+1]]),a(1,5,9,13,r[b[n*16+2]],r[b[n*16+3]]),a(2,6,10,14,r[b[n*16+4]],r[b[n*16+5]]),a(3,7,11,15,r[b[n*16+6]],r[b[n*16+7]]),a(0,5,10,15,r[b[n*16+8]],r[b[n*16+9]]),a(1,6,11,12,r[b[n*16+10]],r[b[n*16+11]]),a(2,7,8,13,r[b[n*16+12]],r[b[n*16+13]]),a(3,4,9,14,r[b[n*16+14]],r[b[n*16+15]]);for(n=0;n<8;n++)f.h[n]^=c[n]^c[n+8]}function h(f,l){if(!(f>0&&f<=32))throw new Error("Incorrect output length, should be in [1, 32]");const n=l?l.length:0;if(l&&!(n>0&&n<=32))throw new Error("Incorrect key length, should be in [1, 32]");const t={h:new Uint32Array(p),b:new Uint8Array(64),c:0,t:0,outlen:f};return t.h[0]^=16842752^n<<8^f,n>0&&(w(t,l),t.c=64),t}function w(f,l){for(let n=0;n>2]>>8*(n&3)&255;return l}function E(f,l,n){n=n||32,f=s.normalizeInput(f);const t=h(n,l);return w(t,f),k(t)}function A(f,l,n){const t=E(f,l,n);return s.toHex(t)}return N={blake2s:E,blake2sHex:A,blake2sInit:h,blake2sUpdate:w,blake2sFinal:k},N}var v,V;function te(){if(V)return v;V=1;const s=Z(),e=ee();return v={blake2b:s.blake2b,blake2bHex:s.blake2bHex,blake2bInit:s.blake2bInit,blake2bUpdate:s.blake2bUpdate,blake2bFinal:s.blake2bFinal,blake2s:e.blake2s,blake2sHex:e.blake2sHex,blake2sInit:e.blake2sInit,blake2sUpdate:e.blake2sUpdate,blake2sFinal:e.blake2sFinal},v}var K=te();const ne=L({bits:24,rounds:23,rightRotations:8,leftRotations:3});function re(s){const e=K.blake2bHex(s,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 oe(s,e){if(!s||s.length===0)return"";const a=s[0];return s.slice(1).map((p,b)=>{const c=a*16777216+(b&16777215),r=ne.encrypt(c,e),i=(p^r)>>>0;try{return String.fromCodePoint(i)}catch{return""}}).join("")}const ie=L();function se(s){const e=K.blake2bHex(s,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 ce(s,e){return s.map(a=>{try{return String.fromCodePoint(ie.decrypt(a,e))}catch{return""}}).join("")}const _="‍​­",x={3:"‍​­᠎‍",6:"‍​­‌‍",8:"‍​­‌‌"},X={1:"SPECK48_96CTR",2:"SPECK32_64ECB (insecure)"};Object.fromEntries(Object.entries(X).map(([s,e])=>[e,+s]));function le(s){if(!s.includes(_))return null;const e=Object.keys(x).find(b=>s.includes(x[b]));if(!e)return null;const a=s.indexOf(x[e]),d=s.slice(a+x[e].length),p=I[e].unifier+I[e][0];if(d.startsWith(p)){const c=Array.from(d.slice(p.length,p.length+3)).map(w=>Object.keys(I[e]).find(k=>I[e][k]===w)).join(""),r=X[parseInt(c,e)],i=d.slice(p.length+3),h=x[e].length+p.length+3;return{base:e,cipher:r,payload:i,sigIdx:a,sigLen:h}}return{base:e,cipher:"PLAIN",payload:d,sigIdx:a,sigLen:x[e].length}}function ae(s,e,a){const d=new Set(Object.values(I[e]));let p=a;for(;pfe(i,e),F(i)}function F(o){const{wrap:e,node:l,start:b,end:d}=o;if(!l.isConnected){e.remove(),x.delete(o);return}const p=document.createRange();try{p.setStart(l,b),p.setEnd(l,Math.min(d,l.nodeValue.length))}catch{e.remove(),x.delete(o);return}let c=p.getBoundingClientRect();!c.width&&!c.height&&l.parentElement&&(c=l.parentElement.getBoundingClientRect());const s=c.left+window.scrollX+(c.width||0)/2,i=c.top+window.scrollY;e.style.left=`${s-e.offsetWidth/2}px`,e.style.top=`${i-e.offsetHeight-2}px`}function fe(o,e){const{wrap:l,node:b,start:d,end:p}=o,c=b.nodeValue.slice(d+e.sigLen,p);let s="";if(e.cipher==="PLAIN")try{s=y.decodeToString(c,e.base)}catch(i){console.error(i)}else{const i=prompt(`inØsight: enter password (${e.cipher}):`);if(!i)return;try{const h=y.decodeToNumberArray(c,e.base);e.cipher==="SPECK48_96CTR"?s=re(h,ne(i)):e.cipher==="SPECK32_64ECB (insecure)"&&(s=se(h,ie(i)))}catch(h){console.error(h)}if(!s){alert("Decryption failed.");return}}if(s){const i=document.createRange();i.setStart(b,d),i.setEnd(b,p),i.deleteContents();const h=document.createElement("span");h.className="inzerosight-decoded",h.style.color="#00b4d8",h.style.fontWeight="600",h.textContent=` ${s} `,i.insertNode(h),l.remove(),x.delete(o)}}const W=new WeakSet;function O(o){if(!o||o.nodeType!==Node.TEXT_NODE||W.has(o))return;const e=o.nodeValue;if(!e||!e.includes(K))return;W.add(o);let l=0;for(;l{var p;return e[(p=d.parentElement)==null?void 0:p.tagName]?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}});let b;for(;b=l.nextNode();)O(b)}$(document.body),new MutationObserver(o=>{for(const e of o)if(e.type==="characterData")O(e.target);else for(const l of e.addedNodes)l.nodeType===Node.TEXT_NODE?O(l):l.nodeType===Node.ELEMENT_NODE&&l.id!=="in0-host"&&$(l)}).observe(document.documentElement,{childList:!0,subtree:!0,characterData:!0}),window.addEventListener("scroll",()=>x.forEach(F),{passive:!0}),window.addEventListener("resize",()=>x.forEach(F),{passive:!0})})(); + `,j.appendChild(s),(document.body||document.documentElement).appendChild(R)}function fe(s,e,a,d){for(const h of T)if(h.node===s&&h.start===a)return;ue();const p=document.createElement("div");p.className="in0-wrap";const b=document.createElement("button");b.className="in0-btn",b.textContent=e.cipher==="PLAIN"?"Decode":"Decrypt";const c=document.createElement("span");c.className="in0-badge",c.textContent="Ø",b.appendChild(c);const r=document.createElement("div");r.className="in0-arrow",p.appendChild(b),p.appendChild(r),j.appendChild(p);const i={wrap:p,node:s,start:a,end:d};T.add(i),b.onclick=()=>de(i,e),W(i)}function W(s){const{wrap:e,node:a,start:d,end:p}=s;if(!a.isConnected){e.remove(),T.delete(s);return}const b=a.parentElement;if(!b||b.checkVisibility&&!b.checkVisibility({checkOpacity:!0,checkVisibilityCSS:!0})){e.style.display="none";return}const c=document.createRange();try{c.setStart(a,d),c.setEnd(a,Math.min(p,a.nodeValue.length))}catch{e.remove(),T.delete(s);return}let r=c.getBoundingClientRect();if(!r.width&&!r.height&&(r=b.getBoundingClientRect()),!r.width&&!r.height){e.style.display="none";return}if(r.bottom<0||r.top>window.innerHeight||r.right<0||r.left>window.innerWidth){e.style.display="none";return}let i=b;for(;i&&i!==document.body&&i!==document.documentElement;){const k=window.getComputedStyle(i);if(k.overflow!=="visible"||k.overflowX!=="visible"||k.overflowY!=="visible"){const E=i.getBoundingClientRect();if(r.bottomE.bottom||r.rightE.right){e.style.display="none";return}}i=i.parentElement}e.style.display="flex";const h=r.left+(r.width||0)/2,w=r.top;e.style.left=`${h-e.offsetWidth/2}px`,e.style.top=`${w-e.offsetHeight-2}px`}function de(s,e){const{wrap:a,node:d,start:p,end:b}=s,c=d.nodeValue.slice(p+e.sigLen,b);let r="";if(e.cipher==="PLAIN")try{r=I.decodeToString(c,e.base)}catch(i){console.error(i)}else{const i=prompt(`inØsight: enter password (${e.cipher}):`);if(!i)return;try{const h=I.decodeToNumberArray(c,e.base);e.cipher==="SPECK48_96CTR"?r=oe(h,re(i)):e.cipher==="SPECK32_64ECB (insecure)"&&(r=ce(h,se(i)))}catch(h){console.error(h)}if(!r){alert("Decryption failed.");return}}if(r){const i=document.createRange();i.setStart(d,p),i.setEnd(d,b),i.deleteContents();const h=document.createElement("span");h.className="inzerosight-decoded",h.style.color="#00b4d8",h.style.fontWeight="600",h.textContent=` ${r} `,i.insertNode(h),a.remove(),T.delete(s)}}function F(s){if(!s||s.nodeType!==Node.TEXT_NODE)return;const e=s.nodeValue;if(!e||!e.includes(_))return;let a=0;for(;a{var b;return e[(b=p.parentElement)==null?void 0:b.tagName]?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}});let d;for(;d=a.nextNode();)F(d)}$(document.body);let O;function P(){O||T.size===0||(O=requestAnimationFrame(()=>{O=null,T.forEach(W)}))}new MutationObserver(s=>{var e;for(const a of[...T])(!a.node.isConnected||!((e=a.node.nodeValue)!=null&&e.includes(_)))&&(a.wrap.remove(),T.delete(a));for(const a of s)if(a.type==="characterData")F(a.target);else for(const d of a.addedNodes)d.nodeType===Node.TEXT_NODE?F(d):d.nodeType===Node.ELEMENT_NODE&&d.id!=="in0-host"&&$(d);P()}).observe(document.documentElement,{childList:!0,subtree:!0,characterData:!0}),window.addEventListener("scroll",P,{capture:!0,passive:!0}),window.addEventListener("resize",P,{passive:!0})})(); diff --git a/dist/firefox/content.js b/dist/firefox/content.js index 869442e..096fbc0 100644 --- a/dist/firefox/content.js +++ b/dist/firefox/content.js @@ -1,14 +1,15 @@ -(function(){"use strict";const y={3:{unifier:"­",0:"᠎",1:"​",2:"‍"},6:{unifier:"‌",0:"‍",1:"‏",2:"­",3:"⁠",4:"​",5:"‎"},8:{unifier:"‌",0:"‍",1:"‏",2:"­",3:"⁠",4:"​",5:"‎",6:"᠎",7:"\uFEFF"},encodeString:(o,e=3)=>Array.from(o,l=>l.codePointAt(0).toString(e).split("").map(b=>y[e][b]).join("")).join(y[e].unifier),encodeNumberArray:(o,e=3)=>o.map(l=>l.toString(e).split("").map(b=>y[e][b]).join("")).join(y[e].unifier),decodeToString:(o,e=3)=>o.split(y[e].unifier).map(l=>String.fromCodePoint(parseInt(Array.from(l).map(b=>Object.keys(y[e]).find(d=>y[e][d]===b)).join(""),e))).join(""),decodeToNumberArray:(o,e=3)=>o.split(y[e].unifier).map(l=>parseInt(Array.from(l).map(b=>Object.keys(y[e]).find(d=>y[e][d]===b)).join(""),e))};function V(o){return o&&o.__esModule&&Object.prototype.hasOwnProperty.call(o,"default")?o.default:o}var D,P;function Y(){if(P)return D;P=1;function o(e={}){const l=e.bits||16,b=e.rounds||22,d=e.rightRotations||7,p=e.leftRotations||2,c=2**l,s=c-1,i=(a,n)=>a>>n|a<a<>l-n,m=(a,n,t)=>(a=i(a,d),a=a+n&s,a^=t,n=h(n,p),n^=a,[a,n]),E=(a,n,t)=>(n^=a,n=i(n,p),a^=t,a=a-n&s,a=h(a,d),[a,n]);function I(a,n){let t=a[0],u=a[1],r=n[0],g=n.slice(1);[u,t]=m(u,t,r);for(let w=0;w{const u=a([n/c|0,n&s],t);return u[0]*c+u[1]}}return{encrypt:f(I),decrypt:f(A),encryptRaw:I,decryptRaw:A}}return D=o,D}var J=Y();const v=V(J);var U,H;function L(){if(H)return U;H=1;const o="Input must be an string, Buffer or Uint8Array";function e(c){let s;if(c instanceof Uint8Array)s=c;else if(typeof c=="string")s=new TextEncoder().encode(c);else throw new Error(o);return s}function l(c){return Array.prototype.map.call(c,function(s){return(s<16?"0":"")+s.toString(16)}).join("")}function b(c){return(4294967296+c).toString(16).substring(1)}function d(c,s,i){let h=` -`+c+" = ";for(let m=0;m=4294967296&&w++,t[u]=g,t[u+1]=w}function l(t,u,r,g){let w=t[u]+r;r<0&&(w+=4294967296);let k=t[u+1]+g;w>=4294967296&&k++,t[u]=w,t[u+1]=k}function b(t,u){return t[u]^t[u+1]<<8^t[u+2]<<16^t[u+3]<<24}function d(t,u,r,g,w,k){const de=h[w],pe=h[w+1],be=h[k],he=h[k+1];e(i,t,u),l(i,t,de,pe);let S=i[g]^i[t],T=i[g+1]^i[t+1];i[g]=T,i[g+1]=S,e(i,r,g),S=i[u]^i[r],T=i[u+1]^i[r+1],i[u]=S>>>24^T<<8,i[u+1]=T>>>24^S<<8,e(i,t,u),l(i,t,be,he),S=i[g]^i[t],T=i[g+1]^i[t+1],i[g]=S>>>16^T<<16,i[g+1]=T>>>16^S<<16,e(i,r,g),S=i[u]^i[r],T=i[u+1]^i[r+1],i[u]=T>>>31^S<<1,i[u+1]=S>>>31^T<<1}const p=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(t){return t*2})),i=new Uint32Array(32),h=new Uint32Array(32);function m(t,u){let r=0;for(r=0;r<16;r++)i[r]=t.h[r],i[r+16]=p[r];for(i[24]=i[24]^t.t,i[25]=i[25]^t.t/4294967296,u&&(i[28]=~i[28],i[29]=~i[29]),r=0;r<32;r++)h[r]=b(t.b,4*r);for(r=0;r<12;r++)d(0,8,16,24,s[r*16+0],s[r*16+1]),d(2,10,18,26,s[r*16+2],s[r*16+3]),d(4,12,20,28,s[r*16+4],s[r*16+5]),d(6,14,22,30,s[r*16+6],s[r*16+7]),d(0,10,20,30,s[r*16+8],s[r*16+9]),d(2,12,22,24,s[r*16+10],s[r*16+11]),d(4,14,16,26,s[r*16+12],s[r*16+13]),d(6,8,18,28,s[r*16+14],s[r*16+15]);for(r=0;r<16;r++)t.h[r]=t.h[r]^i[r]^i[r+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 I(t,u,r,g){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(g&&g.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};E.fill(0),E[0]=t,u&&(E[1]=u.length),E[2]=1,E[3]=1,r&&E.set(r,32),g&&E.set(g,48);for(let k=0;k<16;k++)w.h[k]=p[k]^b(E,k*4);return u&&(A(w,u),w.c=128),w}function A(t,u){for(let r=0;r>2]>>8*(r&3);return u}function a(t,u,r,g,w){r=r||64,t=o.normalizeInput(t),g&&(g=o.normalizeInput(g)),w&&(w=o.normalizeInput(w));const k=I(r,u,g,w);return A(k,t),f(k)}function n(t,u,r,g,w){const k=a(t,u,r,g,w);return o.toHex(k)}return B={blake2b:a,blake2bHex:n,blake2bInit:I,blake2bUpdate:A,blake2bFinal:f},B}var N,z;function Z(){if(z)return N;z=1;const o=L();function e(f,a){return f[a]^f[a+1]<<8^f[a+2]<<16^f[a+3]<<24}function l(f,a,n,t,u,r){c[f]=c[f]+c[a]+u,c[t]=b(c[t]^c[f],16),c[n]=c[n]+c[t],c[a]=b(c[a]^c[n],12),c[f]=c[f]+c[a]+r,c[t]=b(c[t]^c[f],8),c[n]=c[n]+c[t],c[a]=b(c[a]^c[n],7)}function b(f,a){return f>>>a^f<<32-a}const d=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),p=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 i(f,a){let n=0;for(n=0;n<8;n++)c[n]=f.h[n],c[n+8]=d[n];for(c[12]^=f.t,c[13]^=f.t/4294967296,a&&(c[14]=~c[14]),n=0;n<16;n++)s[n]=e(f.b,4*n);for(n=0;n<10;n++)l(0,4,8,12,s[p[n*16+0]],s[p[n*16+1]]),l(1,5,9,13,s[p[n*16+2]],s[p[n*16+3]]),l(2,6,10,14,s[p[n*16+4]],s[p[n*16+5]]),l(3,7,11,15,s[p[n*16+6]],s[p[n*16+7]]),l(0,5,10,15,s[p[n*16+8]],s[p[n*16+9]]),l(1,6,11,12,s[p[n*16+10]],s[p[n*16+11]]),l(2,7,8,13,s[p[n*16+12]],s[p[n*16+13]]),l(3,4,9,14,s[p[n*16+14]],s[p[n*16+15]]);for(n=0;n<8;n++)f.h[n]^=c[n]^c[n+8]}function h(f,a){if(!(f>0&&f<=32))throw new Error("Incorrect output length, should be in [1, 32]");const n=a?a.length:0;if(a&&!(n>0&&n<=32))throw new Error("Incorrect key length, should be in [1, 32]");const t={h:new Uint32Array(d),b:new Uint8Array(64),c:0,t:0,outlen:f};return t.h[0]^=16842752^n<<8^f,n>0&&(m(t,a),t.c=64),t}function m(f,a){for(let n=0;n>2]>>8*(n&3)&255;return a}function I(f,a,n){n=n||32,f=o.normalizeInput(f);const t=h(n,a);return m(t,f),E(t)}function A(f,a,n){const t=I(f,a,n);return o.toHex(t)}return N={blake2s:I,blake2sHex:A,blake2sInit:h,blake2sUpdate:m,blake2sFinal:E},N}var _,G;function ee(){if(G)return _;G=1;const o=Q(),e=Z();return _={blake2b:o.blake2b,blake2bHex:o.blake2bHex,blake2bInit:o.blake2bInit,blake2bUpdate:o.blake2bUpdate,blake2bFinal:o.blake2bFinal,blake2s:e.blake2s,blake2sHex:e.blake2sHex,blake2sInit:e.blake2sInit,blake2sUpdate:e.blake2sUpdate,blake2sFinal:e.blake2sFinal},_}var q=ee();const te=v({bits:24,rounds:23,rightRotations:8,leftRotations:3});function ne(o){const e=q.blake2bHex(o,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 re(o,e){if(!o||o.length===0)return"";const l=o[0];return o.slice(1).map((d,p)=>{const c=l*16777216+(p&16777215),s=te.encrypt(c,e),i=(d^s)>>>0;try{return String.fromCodePoint(i)}catch{return""}}).join("")}const oe=v();function ie(o){const e=q.blake2bHex(o,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 se(o,e){return o.map(l=>{try{return String.fromCodePoint(oe.decrypt(l,e))}catch{return""}}).join("")}const K="‍​­",C={3:"‍​­᠎‍",6:"‍​­‌‍",8:"‍​­‌‌"},X={1:"SPECK48_96CTR",2:"SPECK32_64ECB (insecure)"};Object.fromEntries(Object.entries(X).map(([o,e])=>[e,+o]));function ce(o){if(!o.includes(K))return null;const e=Object.keys(C).find(p=>o.includes(C[p]));if(!e)return null;const l=o.indexOf(C[e]),b=o.slice(l+C[e].length),d=y[e].unifier+y[e][0];if(b.startsWith(d)){const c=Array.from(b.slice(d.length,d.length+3)).map(m=>Object.keys(y[e]).find(E=>y[e][E]===m)).join(""),s=X[parseInt(c,e)],i=b.slice(d.length+3),h=C[e].length+d.length+3;return{base:e,cipher:s,payload:i,sigIdx:l,sigLen:h}}return{base:e,cipher:"PLAIN",payload:b,sigIdx:l,sigLen:C[e].length}}function ae(o,e,l){const b=new Set(Object.values(y[e]));let d=l;for(;dArray.from(s,a=>a.codePointAt(0).toString(e).split("").map(d=>I[e][d]).join("")).join(I[e].unifier),encodeNumberArray:(s,e=3)=>s.map(a=>a.toString(e).split("").map(d=>I[e][d]).join("")).join(I[e].unifier),decodeToString:(s,e=3)=>s.split(I[e].unifier).map(a=>String.fromCodePoint(parseInt(Array.from(a).map(d=>Object.keys(I[e]).find(p=>I[e][p]===d)).join(""),e))).join(""),decodeToNumberArray:(s,e=3)=>s.split(I[e].unifier).map(a=>parseInt(Array.from(a).map(d=>Object.keys(I[e]).find(p=>I[e][p]===d)).join(""),e))};function Y(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var U,H;function J(){if(H)return U;H=1;function s(e={}){const a=e.bits||16,d=e.rounds||22,p=e.rightRotations||7,b=e.leftRotations||2,c=2**a,r=c-1,i=(l,n)=>l>>n|l<l<>a-n,w=(l,n,t)=>(l=i(l,p),l=l+n&r,l^=t,n=h(n,b),n^=l,[l,n]),k=(l,n,t)=>(n^=l,n=i(n,b),l^=t,l=l-n&r,l=h(l,p),[l,n]);function E(l,n){let t=l[0],u=l[1],o=n[0],g=n.slice(1);[u,t]=w(u,t,o);for(let m=0;m{const u=l([n/c|0,n&r],t);return u[0]*c+u[1]}}return{encrypt:f(E),decrypt:f(A),encryptRaw:E,decryptRaw:A}}return U=s,U}var Q=J();const L=Y(Q);var D,z;function M(){if(z)return D;z=1;const s="Input must be an string, Buffer or Uint8Array";function e(c){let r;if(c instanceof Uint8Array)r=c;else if(typeof c=="string")r=new TextEncoder().encode(c);else throw new Error(s);return r}function a(c){return Array.prototype.map.call(c,function(r){return(r<16?"0":"")+r.toString(16)}).join("")}function d(c){return(4294967296+c).toString(16).substring(1)}function p(c,r,i){let h=` +`+c+" = ";for(let w=0;w=4294967296&&m++,t[u]=g,t[u+1]=m}function a(t,u,o,g){let m=t[u]+o;o<0&&(m+=4294967296);let y=t[u+1]+g;m>=4294967296&&y++,t[u]=m,t[u+1]=y}function d(t,u){return t[u]^t[u+1]<<8^t[u+2]<<16^t[u+3]<<24}function p(t,u,o,g,m,y){const pe=h[m],be=h[m+1],he=h[y],ge=h[y+1];e(i,t,u),a(i,t,pe,be);let C=i[g]^i[t],S=i[g+1]^i[t+1];i[g]=S,i[g+1]=C,e(i,o,g),C=i[u]^i[o],S=i[u+1]^i[o+1],i[u]=C>>>24^S<<8,i[u+1]=S>>>24^C<<8,e(i,t,u),a(i,t,he,ge),C=i[g]^i[t],S=i[g+1]^i[t+1],i[g]=C>>>16^S<<16,i[g+1]=S>>>16^C<<16,e(i,o,g),C=i[u]^i[o],S=i[u+1]^i[o+1],i[u]=S>>>31^C<<1,i[u+1]=C>>>31^S<<1}const b=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],r=new Uint8Array(c.map(function(t){return t*2})),i=new Uint32Array(32),h=new Uint32Array(32);function w(t,u){let o=0;for(o=0;o<16;o++)i[o]=t.h[o],i[o+16]=b[o];for(i[24]=i[24]^t.t,i[25]=i[25]^t.t/4294967296,u&&(i[28]=~i[28],i[29]=~i[29]),o=0;o<32;o++)h[o]=d(t.b,4*o);for(o=0;o<12;o++)p(0,8,16,24,r[o*16+0],r[o*16+1]),p(2,10,18,26,r[o*16+2],r[o*16+3]),p(4,12,20,28,r[o*16+4],r[o*16+5]),p(6,14,22,30,r[o*16+6],r[o*16+7]),p(0,10,20,30,r[o*16+8],r[o*16+9]),p(2,12,22,24,r[o*16+10],r[o*16+11]),p(4,14,16,26,r[o*16+12],r[o*16+13]),p(6,8,18,28,r[o*16+14],r[o*16+15]);for(o=0;o<16;o++)t.h[o]=t.h[o]^i[o]^i[o+16]}const k=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 E(t,u,o,g){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(o&&o.length!==16)throw new Error("Illegal salt, expected Uint8Array with length is 16");if(g&&g.length!==16)throw new Error("Illegal personal, expected Uint8Array with length is 16");const m={b:new Uint8Array(128),h:new Uint32Array(16),t:0,c:0,outlen:t};k.fill(0),k[0]=t,u&&(k[1]=u.length),k[2]=1,k[3]=1,o&&k.set(o,32),g&&k.set(g,48);for(let y=0;y<16;y++)m.h[y]=b[y]^d(k,y*4);return u&&(A(m,u),m.c=128),m}function A(t,u){for(let o=0;o>2]>>8*(o&3);return u}function l(t,u,o,g,m){o=o||64,t=s.normalizeInput(t),g&&(g=s.normalizeInput(g)),m&&(m=s.normalizeInput(m));const y=E(o,u,g,m);return A(y,t),f(y)}function n(t,u,o,g,m){const y=l(t,u,o,g,m);return s.toHex(y)}return B={blake2b:l,blake2bHex:n,blake2bInit:E,blake2bUpdate:A,blake2bFinal:f},B}var N,q;function ee(){if(q)return N;q=1;const s=M();function e(f,l){return f[l]^f[l+1]<<8^f[l+2]<<16^f[l+3]<<24}function a(f,l,n,t,u,o){c[f]=c[f]+c[l]+u,c[t]=d(c[t]^c[f],16),c[n]=c[n]+c[t],c[l]=d(c[l]^c[n],12),c[f]=c[f]+c[l]+o,c[t]=d(c[t]^c[f],8),c[n]=c[n]+c[t],c[l]=d(c[l]^c[n],7)}function d(f,l){return f>>>l^f<<32-l}const p=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),b=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),r=new Uint32Array(16);function i(f,l){let n=0;for(n=0;n<8;n++)c[n]=f.h[n],c[n+8]=p[n];for(c[12]^=f.t,c[13]^=f.t/4294967296,l&&(c[14]=~c[14]),n=0;n<16;n++)r[n]=e(f.b,4*n);for(n=0;n<10;n++)a(0,4,8,12,r[b[n*16+0]],r[b[n*16+1]]),a(1,5,9,13,r[b[n*16+2]],r[b[n*16+3]]),a(2,6,10,14,r[b[n*16+4]],r[b[n*16+5]]),a(3,7,11,15,r[b[n*16+6]],r[b[n*16+7]]),a(0,5,10,15,r[b[n*16+8]],r[b[n*16+9]]),a(1,6,11,12,r[b[n*16+10]],r[b[n*16+11]]),a(2,7,8,13,r[b[n*16+12]],r[b[n*16+13]]),a(3,4,9,14,r[b[n*16+14]],r[b[n*16+15]]);for(n=0;n<8;n++)f.h[n]^=c[n]^c[n+8]}function h(f,l){if(!(f>0&&f<=32))throw new Error("Incorrect output length, should be in [1, 32]");const n=l?l.length:0;if(l&&!(n>0&&n<=32))throw new Error("Incorrect key length, should be in [1, 32]");const t={h:new Uint32Array(p),b:new Uint8Array(64),c:0,t:0,outlen:f};return t.h[0]^=16842752^n<<8^f,n>0&&(w(t,l),t.c=64),t}function w(f,l){for(let n=0;n>2]>>8*(n&3)&255;return l}function E(f,l,n){n=n||32,f=s.normalizeInput(f);const t=h(n,l);return w(t,f),k(t)}function A(f,l,n){const t=E(f,l,n);return s.toHex(t)}return N={blake2s:E,blake2sHex:A,blake2sInit:h,blake2sUpdate:w,blake2sFinal:k},N}var v,V;function te(){if(V)return v;V=1;const s=Z(),e=ee();return v={blake2b:s.blake2b,blake2bHex:s.blake2bHex,blake2bInit:s.blake2bInit,blake2bUpdate:s.blake2bUpdate,blake2bFinal:s.blake2bFinal,blake2s:e.blake2s,blake2sHex:e.blake2sHex,blake2sInit:e.blake2sInit,blake2sUpdate:e.blake2sUpdate,blake2sFinal:e.blake2sFinal},v}var K=te();const ne=L({bits:24,rounds:23,rightRotations:8,leftRotations:3});function re(s){const e=K.blake2bHex(s,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 oe(s,e){if(!s||s.length===0)return"";const a=s[0];return s.slice(1).map((p,b)=>{const c=a*16777216+(b&16777215),r=ne.encrypt(c,e),i=(p^r)>>>0;try{return String.fromCodePoint(i)}catch{return""}}).join("")}const ie=L();function se(s){const e=K.blake2bHex(s,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 ce(s,e){return s.map(a=>{try{return String.fromCodePoint(ie.decrypt(a,e))}catch{return""}}).join("")}const _="‍​­",x={3:"‍​­᠎‍",6:"‍​­‌‍",8:"‍​­‌‌"},X={1:"SPECK48_96CTR",2:"SPECK32_64ECB (insecure)"};Object.fromEntries(Object.entries(X).map(([s,e])=>[e,+s]));function le(s){if(!s.includes(_))return null;const e=Object.keys(x).find(b=>s.includes(x[b]));if(!e)return null;const a=s.indexOf(x[e]),d=s.slice(a+x[e].length),p=I[e].unifier+I[e][0];if(d.startsWith(p)){const c=Array.from(d.slice(p.length,p.length+3)).map(w=>Object.keys(I[e]).find(k=>I[e][k]===w)).join(""),r=X[parseInt(c,e)],i=d.slice(p.length+3),h=x[e].length+p.length+3;return{base:e,cipher:r,payload:i,sigIdx:a,sigLen:h}}return{base:e,cipher:"PLAIN",payload:d,sigIdx:a,sigLen:x[e].length}}function ae(s,e,a){const d=new Set(Object.values(I[e]));let p=a;for(;pfe(i,e),F(i)}function F(o){const{wrap:e,node:l,start:b,end:d}=o;if(!l.isConnected){e.remove(),x.delete(o);return}const p=document.createRange();try{p.setStart(l,b),p.setEnd(l,Math.min(d,l.nodeValue.length))}catch{e.remove(),x.delete(o);return}let c=p.getBoundingClientRect();!c.width&&!c.height&&l.parentElement&&(c=l.parentElement.getBoundingClientRect());const s=c.left+window.scrollX+(c.width||0)/2,i=c.top+window.scrollY;e.style.left=`${s-e.offsetWidth/2}px`,e.style.top=`${i-e.offsetHeight-2}px`}function fe(o,e){const{wrap:l,node:b,start:d,end:p}=o,c=b.nodeValue.slice(d+e.sigLen,p);let s="";if(e.cipher==="PLAIN")try{s=y.decodeToString(c,e.base)}catch(i){console.error(i)}else{const i=prompt(`inØsight: enter password (${e.cipher}):`);if(!i)return;try{const h=y.decodeToNumberArray(c,e.base);e.cipher==="SPECK48_96CTR"?s=re(h,ne(i)):e.cipher==="SPECK32_64ECB (insecure)"&&(s=se(h,ie(i)))}catch(h){console.error(h)}if(!s){alert("Decryption failed.");return}}if(s){const i=document.createRange();i.setStart(b,d),i.setEnd(b,p),i.deleteContents();const h=document.createElement("span");h.className="inzerosight-decoded",h.style.color="#00b4d8",h.style.fontWeight="600",h.textContent=` ${s} `,i.insertNode(h),l.remove(),x.delete(o)}}const W=new WeakSet;function O(o){if(!o||o.nodeType!==Node.TEXT_NODE||W.has(o))return;const e=o.nodeValue;if(!e||!e.includes(K))return;W.add(o);let l=0;for(;l{var p;return e[(p=d.parentElement)==null?void 0:p.tagName]?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}});let b;for(;b=l.nextNode();)O(b)}$(document.body),new MutationObserver(o=>{for(const e of o)if(e.type==="characterData")O(e.target);else for(const l of e.addedNodes)l.nodeType===Node.TEXT_NODE?O(l):l.nodeType===Node.ELEMENT_NODE&&l.id!=="in0-host"&&$(l)}).observe(document.documentElement,{childList:!0,subtree:!0,characterData:!0}),window.addEventListener("scroll",()=>x.forEach(F),{passive:!0}),window.addEventListener("resize",()=>x.forEach(F),{passive:!0})})(); + `,j.appendChild(s),(document.body||document.documentElement).appendChild(R)}function fe(s,e,a,d){for(const h of T)if(h.node===s&&h.start===a)return;ue();const p=document.createElement("div");p.className="in0-wrap";const b=document.createElement("button");b.className="in0-btn",b.textContent=e.cipher==="PLAIN"?"Decode":"Decrypt";const c=document.createElement("span");c.className="in0-badge",c.textContent="Ø",b.appendChild(c);const r=document.createElement("div");r.className="in0-arrow",p.appendChild(b),p.appendChild(r),j.appendChild(p);const i={wrap:p,node:s,start:a,end:d};T.add(i),b.onclick=()=>de(i,e),W(i)}function W(s){const{wrap:e,node:a,start:d,end:p}=s;if(!a.isConnected){e.remove(),T.delete(s);return}const b=a.parentElement;if(!b||b.checkVisibility&&!b.checkVisibility({checkOpacity:!0,checkVisibilityCSS:!0})){e.style.display="none";return}const c=document.createRange();try{c.setStart(a,d),c.setEnd(a,Math.min(p,a.nodeValue.length))}catch{e.remove(),T.delete(s);return}let r=c.getBoundingClientRect();if(!r.width&&!r.height&&(r=b.getBoundingClientRect()),!r.width&&!r.height){e.style.display="none";return}if(r.bottom<0||r.top>window.innerHeight||r.right<0||r.left>window.innerWidth){e.style.display="none";return}let i=b;for(;i&&i!==document.body&&i!==document.documentElement;){const k=window.getComputedStyle(i);if(k.overflow!=="visible"||k.overflowX!=="visible"||k.overflowY!=="visible"){const E=i.getBoundingClientRect();if(r.bottomE.bottom||r.rightE.right){e.style.display="none";return}}i=i.parentElement}e.style.display="flex";const h=r.left+(r.width||0)/2,w=r.top;e.style.left=`${h-e.offsetWidth/2}px`,e.style.top=`${w-e.offsetHeight-2}px`}function de(s,e){const{wrap:a,node:d,start:p,end:b}=s,c=d.nodeValue.slice(p+e.sigLen,b);let r="";if(e.cipher==="PLAIN")try{r=I.decodeToString(c,e.base)}catch(i){console.error(i)}else{const i=prompt(`inØsight: enter password (${e.cipher}):`);if(!i)return;try{const h=I.decodeToNumberArray(c,e.base);e.cipher==="SPECK48_96CTR"?r=oe(h,re(i)):e.cipher==="SPECK32_64ECB (insecure)"&&(r=ce(h,se(i)))}catch(h){console.error(h)}if(!r){alert("Decryption failed.");return}}if(r){const i=document.createRange();i.setStart(d,p),i.setEnd(d,b),i.deleteContents();const h=document.createElement("span");h.className="inzerosight-decoded",h.style.color="#00b4d8",h.style.fontWeight="600",h.textContent=` ${r} `,i.insertNode(h),a.remove(),T.delete(s)}}function F(s){if(!s||s.nodeType!==Node.TEXT_NODE)return;const e=s.nodeValue;if(!e||!e.includes(_))return;let a=0;for(;a{var b;return e[(b=p.parentElement)==null?void 0:b.tagName]?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}});let d;for(;d=a.nextNode();)F(d)}$(document.body);let O;function P(){O||T.size===0||(O=requestAnimationFrame(()=>{O=null,T.forEach(W)}))}new MutationObserver(s=>{var e;for(const a of[...T])(!a.node.isConnected||!((e=a.node.nodeValue)!=null&&e.includes(_)))&&(a.wrap.remove(),T.delete(a));for(const a of s)if(a.type==="characterData")F(a.target);else for(const d of a.addedNodes)d.nodeType===Node.TEXT_NODE?F(d):d.nodeType===Node.ELEMENT_NODE&&d.id!=="in0-host"&&$(d);P()}).observe(document.documentElement,{childList:!0,subtree:!0,characterData:!0}),window.addEventListener("scroll",P,{capture:!0,passive:!0}),window.addEventListener("resize",P,{passive:!0})})(); diff --git a/dist/web/index.html b/dist/web/index.html index 38990eb..783248c 100644 --- a/dist/web/index.html +++ b/dist/web/index.html @@ -1,33 +1,33 @@ - - - - - + + + + + - - -

inØsight 3.0.0source

- - - - - - -

- notice: some platforms restrict Ø width characters. -

- - + + +

inØsight 3.0.0source

+ + + + + + +

+ notice: some platforms restrict Ø width characters. +

+ +