@filteringdev/namulink 20.1.3 → 20.1.5-build.ba1badcc57e3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,7 +8,7 @@
8
8
  // @downloadURL https://cdn.jsdelivr.net/npm/@filteringdev/namulink@latest/dist/NamuLink.user.js
9
9
  // @license MPL-2.0
10
10
  //
11
- // @version 20.1.3
11
+ // @version 20.1.5-build.ba1badcc57e3
12
12
  // @author PiQuark6046 and contributors
13
13
  //
14
14
  // @grant unsafeWindow
@@ -22,7 +22,7 @@
22
22
  // ==/UserScript==
23
23
 
24
24
 
25
- (()=>{function v(e,r={}){let n=r.QuietMs??120,t=r.EventName??"vue:settled",a=r.ChangeEventName??"vue:dom-changed";if(!(e instanceof HTMLElement))throw new TypeError("TargetEl must be an HTMLElement");let c=-1,l=0,d=!1,u=performance.now(),g=i=>{e.dispatchEvent(new CustomEvent(a,{detail:{Seq:l,At:u,MutationCount:i.length,Mutations:i}}))},h=()=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{d||e.dispatchEvent(new CustomEvent(t,{detail:{Seq:l,QuietMs:n,SettledAt:performance.now(),ElapsedSinceLastMutation:performance.now()-u,Target:e}}))})})},S=()=>{clearTimeout(c),c=setTimeout(h,n)},m=new MutationObserver(i=>{l+=1,u=performance.now(),g(i),i.length>=25&&S()});return m.observe(e,{subtree:!0,childList:!0,attributes:!0,characterData:!0}),S(),{Disconnect(){d=!0,clearTimeout(c),m.disconnect(),e.dispatchEvent(new CustomEvent("vue:observer-disconnected",{detail:{Target:e}}))}}}function b(e,r=document.documentElement){return new Promise(n=>{let t=r.querySelector(e);if(t&&t instanceof HTMLElement){n(t);return}let a=new MutationObserver(()=>{let c=r.querySelector(e);c&&c instanceof HTMLElement&&(a.disconnect(),n(c))});a.observe(r,{subtree:!0,childList:!0,attributes:!0})})}function R(e){let r=e.trim();if(!r||r==="none")return null;let n=r.match(/^url\((.*)\)$/i);if(!n)return null;let t=n[1].trim();return(t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'"))&&(t=t.slice(1,-1)),t}function C(e,r){let n=r;for(;n;){let t=e.getComputedStyle(n).backgroundColor;if(t&&t!=="transparent"&&t!=="rgba(0, 0, 0, 0)")return t;n=n.parentElement}return"rgb(255, 255, 255)"}function T(e,r,n){let t=new Set;function a(l){l&&(l==="transparent"||l==="rgba(0, 0, 0, 0)"||t.add(l))}a(n);let c=e.getComputedStyle(r);if(a(c.backgroundColor),a(c.color),a(e.getComputedStyle(e.document.documentElement).backgroundColor),e.document.body){let l=e.getComputedStyle(e.document.body);a(l.backgroundColor),a(l.color)}return a("rgb(255, 255, 255)"),a("rgb(0, 0, 0)"),[...t]}function H(e,r){if(r instanceof e.HTMLImageElement)return r.currentSrc||r.src||""||null;let n=e.getComputedStyle(r).backgroundImage;return R(n)}function P(e,r){let n=0,t=new Map;r.addEventListener("message",d=>{let u=d.data;if(!u||!("RequestId"in u))return;let g=t.get(u.RequestId);if(g){if(t.delete(u.RequestId),u.Kind==="detect-result"){g.Resolve(u.Result);return}g.Reject(new Error(u.Error))}});function a(d){let u=`ocr-${Date.now()}-${n++}`,g={Kind:"detect",RequestId:u,...d};return new Promise((h,S)=>{t.set(u,{Resolve:h,Reject:S}),r.postMessage(g)})}async function c(d,u){let g=H(e,d);if(!g)return null;let h=await w(e,d,g),S=C(e,d),m=T(e,d,S);return a({ImageData:h,BackgroundCandidates:m,FontCandidates:u?.FontCandidates,ScoreThreshold:u?.ScoreThreshold})}async function l(d){let u=await w(e,d.HostElement,d.SourceUrl),g=C(e,d.HostElement),h=T(e,d.HostElement,g);return a({ImageData:u,BackgroundCandidates:h,FontCandidates:d.FontCandidates,ScoreThreshold:d.ScoreThreshold})}return{DetectFromElement:c,DetectFromSource:l,Terminate(){for(let d of t.values())d.Reject(new Error("OCR worker terminated"));t.clear(),r.terminate()}}}function F(e){return/^data:image\/svg\+xml(?:[;,]|$)/i.test(e)}function x(e,r){let n=e.atob(r),t=new Uint8Array(n.length);for(let a=0;a<n.length;a++)t[a]=n.charCodeAt(a);return new TextDecoder().decode(t)}function D(e,r){let n=r.indexOf(",");if(n<0)throw new Error("Invalid SVG data URL");let t=r.slice(0,n).toLowerCase(),a=r.slice(n+1);return t.includes(";base64")?x(e,a):decodeURIComponent(a)}function k(e,r,n,t){let c=new e.DOMParser().parseFromString(r,"image/svg+xml");if(c.querySelector("parsererror"))throw new Error("Failed to parse SVG markup");let l=c.documentElement;if(!l||l.nodeName.toLowerCase()!=="svg")throw new Error("SVG root element not found");return l.getAttribute("xmlns")||l.setAttribute("xmlns","http://www.w3.org/2000/svg"),l.getAttribute("width")||l.setAttribute("width",String(n)),l.getAttribute("height")||l.setAttribute("height",String(t)),new e.XMLSerializer().serializeToString(c)}function I(e){return e.complete&&e.naturalWidth>0?Promise.resolve():new Promise((r,n)=>{function t(){e.removeEventListener("load",a),e.removeEventListener("error",c)}function a(){t(),r()}function c(){t(),n(new Error("Failed to load SVG image"))}e.addEventListener("load",a),e.addEventListener("error",c)})}async function q(e,r){let n=new e.Image;n.decoding="async",n.src=r;try{if(await n.decode(),n.naturalWidth>0)return n}catch{}return await I(n),n}function M(e){return typeof e=="string"&&/^image\/svg\+xml(?:\s*;|$)/i.test(e)}function A(e,r){let n=r.getBoundingClientRect(),t=Math.max(1,e.devicePixelRatio||1);return{Width:Math.max(1,Math.round((n.width||r.clientWidth||96)*t)),Height:Math.max(1,Math.round((n.height||r.clientHeight||32)*t))}}async function L(e,r,n){let{Width:t,Height:a}=A(e,r),c=k(e,n,t,a),l=e.URL.createObjectURL(new e.Blob([c],{type:"image/svg+xml"}));try{let d=await q(e,l),u=e.document.createElement("canvas");u.width=t,u.height=a;let g=u.getContext("2d",{willReadFrequently:!0});if(!g)throw new Error("2D context unavailable");return g.clearRect(0,0,t,a),g.drawImage(d,0,0,t,a),g.getImageData(0,0,t,a)}finally{e.URL.revokeObjectURL(l)}}async function V(e,r){let n=await e.createImageBitmap(r);try{let t=e.document.createElement("canvas");t.width=n.width,t.height=n.height;let a=t.getContext("2d",{willReadFrequently:!0});if(!a)throw new Error("2D context unavailable");return a.drawImage(n,0,0),a.getImageData(0,0,t.width,t.height)}finally{n.close()}}async function w(e,r,n){if(F(n)){let a=D(e,n);return await L(e,r,a)}let t=await new Promise((a,c)=>{GM.xmlHttpRequest({url:n,method:"GET",responseType:"blob",onload:l=>{if(l.status<200||l.status>=300){c(new Error(`Failed to fetch image: ${l.status} ${l.statusText}`));return}let d=l.response;if(!(d instanceof Blob)){c(new Error("Failed to fetch image: invalid blob response"));return}let u=l.responseHeaders.match(/^content-type:\s*(.+)$/im),g=u?u[1].trim():null;a({BlobData:d,ContentTypeHeader:g})},onerror:c,ontimeout:c})});if(M(t.BlobData.type)||M(t.ContentTypeHeader)){let a=await t.BlobData.text();return await L(e,r,a)}return await V(e,t.BlobData)}var _=typeof unsafeWindow<"u"?unsafeWindow:window;async function O(e,r="NamuLink"){let n=e.Reflect.apply,t=[[/\( *\) *=> *{ *var *_0x[0-9a-z]+ *= *a0_0x[0-9a-f]+ *; *this\[ *_0x[a-z0-9]+\( *0x[0-9a-f]+ *\) *\]\(\); *}/,/\( *\) *=> *{ *var *_0x[0-9a-z]+ *= *a0_0x[0-9a-f]+ *; *this\[ *_0x[a-z0-9]+\( *0x[0-9a-f]+ *\) *\]\(\); *}/],[/\( *\) *=> *{ *var _0x[a-z0-9]+ *= *_0x[a-z0-9]+ *; *if *\( *this\[ *_0x[a-z0-9]+ *\( *0x[0-9a-f]+ *\) *\] *\) *return *clearTimeout/,/\( *0x[0-9a-f]+ *\) *\] *\) *, *void *\( *this\[ *_0x[a-z0-9]+\( *0x[0-9a-f]+ *\) *\] *= *void *\([x0-9a-f*+-]+ *\) *\) *; *this\[_0x[a-z0-9]+\( *0x[0-9a-f]+ *\) *\] *\(\) *;/]];e.setTimeout=new Proxy(e.setTimeout,{apply(m,i,f){let y=String(f[0]);return t.filter(E=>E.filter(o=>o.test(y)).length>=1).length===1?(console.debug(`[${r}]: setTimeout called for PowerLink Skeleton:`,f[0]),n(m,i,[()=>{},0])):n(m,i,f)}});let a=await b("#app",e.document);v(a,{QuietMs:75,EventName:"vue:settled",ChangeEventName:"vue:change"});let d=P(e,new Worker(URL.createObjectURL(new Blob(['(()=>{var b=["\\uD30C\\uC6CC\\uB9C1\\uD06C","\\uAD11\\uACE0","\\uAD11\\uACE0\\uB4F1\\uB85D"],k=["Pretendard JP, sans-serif","Pretendard, sans-serif","system-ui, sans-serif","Apple SD Gothic Neo, sans-serif","Nanum Gothic, sans-serif","Noto Sans KR, sans-serif","Arial, sans-serif"],H=new Map;function T(t,n){return new OffscreenCanvas(Math.max(1,Math.floor(t)),Math.max(1,Math.floor(n)))}function C(t){let n=t.getContext("2d",{willReadFrequently:!0});if(!n)throw new Error("2D context unavailable");return n}function Y(t){let n=C(t),{width:a,height:e}=t,r=n.getImageData(0,0,a,e).data,o=new Uint8ClampedArray(a*e);for(let i=0,s=0;i<r.length;i+=4,s++){let l=r[i],h=r[i+1],g=r[i+2];o[s]=Math.round(.299*l+.587*h+.114*g)}return{Width:a,Height:e,Data:o}}function A(t){let n=new Uint32Array(256);for(let l=0;l<t.Data.length;l++)n[t.Data[l]]++;let a=t.Data.length,e=0;for(let l=0;l<256;l++)e+=l*n[l];let r=0,o=0,i=-1,s=127;for(let l=0;l<256;l++){if(o+=n[l],o===0)continue;let h=a-o;if(h===0)break;r+=l*n[l];let g=r/o,d=(e-r)/h,c=o*h*(g-d)*(g-d);c>i&&(i=c,s=l)}return s}function M(t){let n=A(t),a=0,e=0;for(let i=0;i<t.Data.length;i++)t.Data[i]<n?a++:e++;let r=a<e,o=new Uint8Array(t.Width*t.Height);for(let i=0;i<t.Data.length;i++){let s=r?t.Data[i]<n:t.Data[i]>n;o[i]=s?1:0}return{Width:t.Width,Height:t.Height,Data:o}}function O(t){let n=new Uint8Array(t.Width*t.Height);for(let a=1;a<t.Height-1;a++)for(let e=1;e<t.Width-1;e++){let r=1;for(let o=-1;o<=1&&r;o++)for(let i=-1;i<=1;i++)if(t.Data[(a+o)*t.Width+(e+i)]===0){r=0;break}n[a*t.Width+e]=r}return{Width:t.Width,Height:t.Height,Data:n}}function w(t){let n=new Uint8Array(t.Width*t.Height);for(let a=1;a<t.Height-1;a++)for(let e=1;e<t.Width-1;e++){let r=0;for(let o=-1;o<=1&&!r;o++)for(let i=-1;i<=1;i++)if(t.Data[(a+o)*t.Width+(e+i)]===1){r=1;break}n[a*t.Width+e]=r}return{Width:t.Width,Height:t.Height,Data:n}}function N(t){return w(O(w(t)))}function v(t,n=20){let a=new Uint8Array(t.Width*t.Height),e=[],r=new Int32Array(t.Width*t.Height),o=new Int32Array(t.Width*t.Height);for(let i=0;i<t.Height;i++)for(let s=0;s<t.Width;s++){let l=i*t.Width+s;if(a[l]||t.Data[l]===0)continue;let h=0,g=0;r[g]=s,o[g]=i,g++,a[l]=1;let d=s,c=i,u=s,f=i,X=0;for(;h<g;){let m=r[h],D=o[h];h++,X++,m<d&&(d=m),D<c&&(c=D),m>u&&(u=m),D>f&&(f=D);for(let I=-1;I<=1;I++)for(let y=-1;y<=1;y++){if(y===0&&I===0)continue;let W=m+y,B=D+I;if(W<0||B<0||W>=t.Width||B>=t.Height)continue;let x=B*t.Width+W;a[x]||t.Data[x]===0||(a[x]=1,r[g]=W,o[g]=B,g++)}}X>=n&&e.push({X:d,Y:c,Width:u-d+1,Height:f-c+1})}return e}function U(t,n=8,a=4){let e=[...t],r=!0;function o(i,s){let l=i.X+i.Width,h=i.Y+i.Height,g=s.X+s.Width,d=s.Y+s.Height;return!(l+n<s.X||g+n<i.X||h+a<s.Y||d+a<i.Y)}for(;r;){r=!1;t:for(let i=0;i<e.length;i++)for(let s=i+1;s<e.length;s++){if(!o(e[i],e[s]))continue;let l=e[i],h=e[s];e[i]={X:Math.min(l.X,h.X),Y:Math.min(l.Y,h.Y),Width:Math.max(l.X+l.Width,h.X+h.Width)-Math.min(l.X,h.X),Height:Math.max(l.Y+l.Height,h.Y+h.Height)-Math.min(l.Y,h.Y)},e.splice(s,1),r=!0;break t}}return e}function R(t,n){let a=new Uint8Array(n.Width*n.Height);for(let e=0;e<n.Height;e++)for(let r=0;r<n.Width;r++)a[e*n.Width+r]=t.Data[(n.Y+e)*t.Width+(n.X+r)];return{Width:n.Width,Height:n.Height,Data:a}}function E(t){let n=t.Width,a=t.Height,e=-1,r=-1;for(let o=0;o<t.Height;o++)for(let i=0;i<t.Width;i++)t.Data[o*t.Width+i]!==0&&(i<n&&(n=i),o<a&&(a=o),i>e&&(e=i),o>r&&(r=o));return e<n||r<a?{Width:1,Height:1,Data:new Uint8Array([0])}:R(t,{X:n,Y:a,Width:e-n+1,Height:r-a+1})}function P(t,n,a){let e=new Uint8Array(n*a);for(let r=0;r<a;r++)for(let o=0;o<n;o++){let i=Math.min(t.Width-1,Math.floor(o/n*t.Width)),s=Math.min(t.Height-1,Math.floor(r/a*t.Height));e[r*n+o]=t.Data[s*t.Width+i]}return{Width:n,Height:a,Data:e}}function p(t,n=64){let a=E(t),e=Math.max(a.Width,a.Height),r=new Uint8Array(e*e),o=Math.floor((e-a.Width)/2),i=Math.floor((e-a.Height)/2);for(let s=0;s<a.Height;s++)for(let l=0;l<a.Width;l++)r[(s+i)*e+(l+o)]=a.Data[s*a.Width+l];return P({Width:e,Height:e,Data:r},n,n)}function F(t,n){if(t.Width!==n.Width||t.Height!==n.Height)throw new Error("Image size mismatch");let a=0;for(let e=0;e<t.Data.length;e++)t.Data[e]!==n.Data[e]&&a++;return a/t.Data.length}function K(t,n){let a=`${t}__${n}`,e=H.get(a);if(e)return e;let r=256,o=96,i=T(r,o),s=C(i);s.fillStyle="white",s.fillRect(0,0,r,o);let l=Math.floor(o*.72);for(;l>8;){s.clearRect(0,0,r,o),s.fillStyle="white",s.fillRect(0,0,r,o),s.fillStyle="black",s.textAlign="center",s.textBaseline="middle",s.font=`700 ${l}px ${n}`;let g=s.measureText(t),d=g.width,c=(g.actualBoundingBoxAscent||l*.8)+(g.actualBoundingBoxDescent||l*.2);if(d<=r*.9&&c<=o*.9){s.fillText(t,r/2,o/2);let u=Y(i),f=p(M(u));return H.set(a,f),f}l--}s.font=`700 12px ${n}`,s.fillStyle="black",s.textAlign="center",s.textBaseline="middle",s.fillText(t,r/2,o/2);let h=p(M(Y(i)));return H.set(a,h),h}function V(t,n,a){let e=p(t),r=Number.POSITIVE_INFINITY;for(let o of a){let i=K(n,o),s=F(e,i);s<r&&(r=s)}return r}function z(t){let n=v(t,16);return U(n,10,6).filter(e=>{if(e.Width<8||e.Height<8)return!1;let r=e.Width/e.Height;return r>.5&&r<12})}async function $(t){let a=q(t.ImageData)?t.BackgroundCandidates:t.BackgroundCandidates.slice(0,1),e=t.FontCandidates??k,r=t.ScoreThreshold??.32,o=null;for(let i of a){let s=_(t.ImageData,i),l=G(s),h=N(M(l)),g=z(h);if(g.length!==0)for(let d of g){let c=R(h,d);for(let u of b){let f=V(c,u,e);(!o||f<o.Score)&&(o={Label:u,Score:f,Box:d})}}}return!o||o.Score>r?null:o}function G(t){let{width:n,height:a,data:e}=t,r=new Uint8ClampedArray(n*a);for(let o=0,i=0;o<e.length;o+=4,i++){let s=e[o],l=e[o+1],h=e[o+2];r[i]=Math.round(.299*s+.587*l+.114*h)}return{Width:n,Height:a,Data:r}}function q(t){let n=t.data;for(let a=3;a<n.length;a+=4)if(n[a]<255)return!0;return!1}function _(t,n){let a=T(t.width,t.height),e=C(a);return e.fillStyle=n,e.fillRect(0,0,t.width,t.height),e.putImageData(t,0,0),e.getImageData(0,0,t.width,t.height)}self.addEventListener("message",t=>{(async()=>{let n=t.data;if(!(!n||n.Kind!=="detect"))try{let a=await $(n),e={Kind:"detect-result",RequestId:n.RequestId,Result:a};self.postMessage(e)}catch(a){let e=a instanceof Error?a.message:String(a),r={Kind:"detect-error",RequestId:n.RequestId,Error:e};self.postMessage(r)}})()});})();\n'],{type:"application/javascript"}))));async function u(m){let i=[];for(let f of m){let y=[...f.querySelectorAll("*")].filter(o=>o instanceof HTMLElement).filter(o=>o instanceof HTMLImageElement||getComputedStyle(o).backgroundImage!=="none").filter(o=>parseFloat(getComputedStyle(o).getPropertyValue("width"))>=5&&parseFloat(getComputedStyle(o).getPropertyValue("height"))>=5).filter(o=>parseFloat(getComputedStyle(o).getPropertyValue("width"))<=50&&parseFloat(getComputedStyle(o).getPropertyValue("height"))<=50),E=0;for(let o of y)if(await d.DetectFromElement(o,{ScoreThreshold:.32})!==null&&(E+=1),E>=1){i.push(f);break}}return i}function g(m){let i=new Set([m]);for(let f=0;;f++){let y=[...i][f].parentElement;if(y===null)break;i.add(y)}return i}async function h(m){let i=[...document.querySelectorAll("#app div[class] div[class] ~ div[class]")].filter(o=>o instanceof HTMLElement);i=i.filter(o=>parseFloat(getComputedStyle(o).getPropertyValue("padding-top"))>=20||parseFloat(getComputedStyle(o).getPropertyValue("margin-top"))>=20||parseFloat(getComputedStyle(o).getPropertyValue("margin-bottom"))>=12.5),i=i.filter(o=>{let p=[...o.querySelectorAll("*")].filter(s=>s instanceof HTMLElement);return p.filter(s=>parseFloat(getComputedStyle(s).getPropertyValue("padding-top"))>=5&&parseFloat(getComputedStyle(s).getPropertyValue("border-bottom-width"))>=.1).length===1?!0:p.filter(s=>(s instanceof HTMLTableElement||s instanceof HTMLTableCellElement)&&parseFloat(getComputedStyle(s).getPropertyValue("padding-top"))>=5&&parseFloat(getComputedStyle(s).getPropertyValue("padding-bottom"))>=5).length>=2}),i=i.filter(o=>![...o.querySelectorAll("*")].filter(s=>s instanceof HTMLElement).some(s=>parseFloat(getComputedStyle(s).getPropertyValue("margin-bottom"))>=10&&parseFloat(getComputedStyle(s).getPropertyValue("padding-bottom"))>=1&&parseFloat(getComputedStyle(s).getPropertyValue("padding-top"))>=1&&parseFloat(getComputedStyle(s).getPropertyValue("border-top-width"))>=.25&&parseFloat(getComputedStyle(s).getPropertyValue("border-bottom-width"))>=.25)),i=i.filter(o=>{let p=[...o.querySelectorAll("*")].filter(s=>s instanceof HTMLElement);return p=p.filter(s=>parseFloat(getComputedStyle(s).getPropertyValue("padding-right"))>=10&&parseFloat(getComputedStyle(s).getPropertyValue("padding-bottom"))>=10),p=p.filter(s=>parseFloat(getComputedStyle(s).getPropertyValue("margin-left"))>=2.5),p.length===0}),i=await u(i),i.forEach(o=>i.push(...new Set([...o.querySelectorAll("*")].filter(p=>p instanceof HTMLElement)))),i=[...new Set(i)];let f=i.filter(o=>parseFloat(getComputedStyle(o).getPropertyValue("padding-left"))>=5&&parseFloat(getComputedStyle(o).getPropertyValue("border-right-width"))>=.1);console.debug(`[${r}] ${m.type} RealTargeted`,f,m),f.forEach(o=>{o.style.setProperty("display","none","important")});let y=i.filter(o=>!(o instanceof HTMLElement)||!(o instanceof HTMLTableElement)?!1:[...o.querySelectorAll("*")].filter(s=>s instanceof HTMLElement).some(s=>parseFloat(getComputedStyle(s).getPropertyValue("padding-top"))>=5&&parseFloat(getComputedStyle(s).getPropertyValue("padding-bottom"))>=5));console.debug(`[${r}] ${m.type} RealTabletTargeted`,y,m),y.forEach(o=>{o.style.setProperty("display","none","important")});let E=new Set([...f,...y]);E.forEach(o=>{[...g(o)].filter(s=>s.innerText.trim().length===0).forEach(s=>E.add(s))}),console.debug(`[${r}] ${m.type} PlaceHolderCandidated`,E,m),[...E].forEach(o=>{o.style.setProperty("display","none","important")})}a.addEventListener("vue:settled",m=>h(m)),["https://fonts.googleapis.com/css2?family=Nanum Gothic&display=swap"].forEach(m=>{let i=e.document.createElement("link");i.rel="stylesheet",i.href=m,e.document.head.appendChild(i)})}O(_);})();
25
+ (()=>{function b(e,r={}){let n=r.QuietMs??120,t=r.EventName??"vue:settled",a=r.ChangeEventName??"vue:dom-changed",d=r.UrlChange??"vue:url-changed";if(!(e instanceof HTMLElement))throw new TypeError("TargetEl must be an HTMLElement");let s=-1,u=0,c=!1,m=performance.now(),h=new URL(location.href),v=p=>{e.dispatchEvent(new CustomEvent(a,{detail:{Seq:u,At:m,MutationCount:p.length,Mutations:p}}))},S=()=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{c||e.dispatchEvent(new CustomEvent(t,{detail:{Seq:u,QuietMs:n,SettledAt:performance.now(),ElapsedSinceLastMutation:performance.now()-m,Target:e}}))})})},g=()=>{let p=new URL(location.href);p.href!==h.href&&(h=p,e.dispatchEvent(new CustomEvent(d,{detail:{Seq:u,At:performance.now(),URL:p}})))},i=()=>{clearTimeout(s),s=setTimeout(S,n)},f=new MutationObserver(p=>{u+=1,m=performance.now(),v(p),p.length>=25&&i(),g()});return f.observe(e,{subtree:!0,childList:!0,attributes:!0,characterData:!0}),i(),{Disconnect(){c=!0,clearTimeout(s),f.disconnect(),e.dispatchEvent(new CustomEvent("vue:observer-disconnected",{detail:{Target:e}}))}}}function M(e,r=document.documentElement){return new Promise(n=>{let t=r.querySelector(e);if(t&&t instanceof HTMLElement){n(t);return}let a=new MutationObserver(()=>{let d=r.querySelector(e);d&&d instanceof HTMLElement&&(a.disconnect(),n(d))});a.observe(r,{subtree:!0,childList:!0,attributes:!0})})}function I(e){let r=e.trim();if(!r||r==="none")return null;let n=r.match(/^url\((.*)\)$/i);if(!n)return null;let t=n[1].trim();return(t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'"))&&(t=t.slice(1,-1)),t}function T(e,r){let n=r;for(;n;){let t=e.getComputedStyle(n).backgroundColor;if(t&&t!=="transparent"&&t!=="rgba(0, 0, 0, 0)")return t;n=n.parentElement}return"rgb(255, 255, 255)"}function L(e,r,n){let t=new Set;function a(s){s&&(s==="transparent"||s==="rgba(0, 0, 0, 0)"||t.add(s))}a(n);let d=e.getComputedStyle(r);if(a(d.backgroundColor),a(d.color),a(e.getComputedStyle(e.document.documentElement).backgroundColor),e.document.body){let s=e.getComputedStyle(e.document.body);a(s.backgroundColor),a(s.color)}return a("rgb(255, 255, 255)"),a("rgb(0, 0, 0)"),[...t]}function k(e,r){if(r instanceof e.HTMLImageElement)return r.currentSrc||r.src||""||null;let n=e.getComputedStyle(r).backgroundImage;return I(n)}function H(e,r){let n=0,t=new Map;r.addEventListener("message",u=>{let c=u.data;if(!c||!("RequestId"in c))return;let m=t.get(c.RequestId);if(m){if(t.delete(c.RequestId),c.Kind==="detect-result"){m.Resolve(c.Result);return}m.Reject(new Error(c.Error))}});function a(u){let c=`ocr-${Date.now()}-${n++}`,m={Kind:"detect",RequestId:c,...u};return new Promise((h,v)=>{t.set(c,{Resolve:h,Reject:v}),r.postMessage(m)})}async function d(u,c){let m=k(e,u);if(!m)return null;let h=await P(e,u,m),v=T(e,u),S=L(e,u,v);return a({ImageData:h,BackgroundCandidates:S,FontCandidates:c?.FontCandidates,ScoreThreshold:c?.ScoreThreshold})}async function s(u){let c=await P(e,u.HostElement,u.SourceUrl),m=T(e,u.HostElement),h=L(e,u.HostElement,m);return a({ImageData:c,BackgroundCandidates:h,FontCandidates:u.FontCandidates,ScoreThreshold:u.ScoreThreshold})}return{DetectFromElement:d,DetectFromSource:s,Terminate(){for(let u of t.values())u.Reject(new Error("OCR worker terminated"));t.clear(),r.terminate()}}}function V(e){return/^data:image\/svg\+xml(?:[;,]|$)/i.test(e)}function q(e,r){let n=e.atob(r),t=new Uint8Array(n.length);for(let a=0;a<n.length;a++)t[a]=n.charCodeAt(a);return new TextDecoder().decode(t)}function A(e,r){let n=r.indexOf(",");if(n<0)throw new Error("Invalid SVG data URL");let t=r.slice(0,n).toLowerCase(),a=r.slice(n+1);return t.includes(";base64")?q(e,a):decodeURIComponent(a)}function U(e,r,n,t){let d=new e.DOMParser().parseFromString(r,"image/svg+xml");if(d.querySelector("parsererror"))throw new Error("Failed to parse SVG markup");let s=d.documentElement;if(!s||s.nodeName.toLowerCase()!=="svg")throw new Error("SVG root element not found");return s.getAttribute("xmlns")||s.setAttribute("xmlns","http://www.w3.org/2000/svg"),s.getAttribute("width")||s.setAttribute("width",String(n)),s.getAttribute("height")||s.setAttribute("height",String(t)),new e.XMLSerializer().serializeToString(d)}function _(e){return e.complete&&e.naturalWidth>0?Promise.resolve():new Promise((r,n)=>{function t(){e.removeEventListener("load",a),e.removeEventListener("error",d)}function a(){t(),r()}function d(){t(),n(new Error("Failed to load SVG image"))}e.addEventListener("load",a),e.addEventListener("error",d)})}async function O(e,r){let n=new e.Image;n.decoding="async",n.src=r;try{if(await n.decode(),n.naturalWidth>0)return n}catch{}return await _(n),n}function w(e){return typeof e=="string"&&/^image\/svg\+xml(?:\s*;|$)/i.test(e)}function N(e,r){let n=r.getBoundingClientRect(),t=Math.max(1,e.devicePixelRatio||1);return{Width:Math.max(1,Math.round((n.width||r.clientWidth||96)*t)),Height:Math.max(1,Math.round((n.height||r.clientHeight||32)*t))}}async function R(e,r,n){let{Width:t,Height:a}=N(e,r),d=U(e,n,t,a),s=e.URL.createObjectURL(new e.Blob([d],{type:"image/svg+xml"}));try{let u=await O(e,s),c=e.document.createElement("canvas");c.width=t,c.height=a;let m=c.getContext("2d",{willReadFrequently:!0});if(!m)throw new Error("2D context unavailable");return m.clearRect(0,0,t,a),m.drawImage(u,0,0,t,a),m.getImageData(0,0,t,a)}finally{e.URL.revokeObjectURL(s)}}async function z(e,r){let n=await e.createImageBitmap(r);try{let t=e.document.createElement("canvas");t.width=n.width,t.height=n.height;let a=t.getContext("2d",{willReadFrequently:!0});if(!a)throw new Error("2D context unavailable");return a.drawImage(n,0,0),a.getImageData(0,0,t.width,t.height)}finally{n.close()}}async function P(e,r,n){if(V(n)){let a=A(e,n);return await R(e,r,a)}let t=await new Promise((a,d)=>{GM.xmlHttpRequest({url:n,method:"GET",responseType:"blob",onload:s=>{if(s.status<200||s.status>=300){d(new Error(`Failed to fetch image: ${s.status} ${s.statusText}`));return}let u=s.response;if(!(u instanceof Blob)){d(new Error("Failed to fetch image: invalid blob response"));return}let c=s.responseHeaders.match(/^content-type:\s*(.+)$/im),m=c?c[1].trim():null;a({BlobData:u,ContentTypeHeader:m})},onerror:d,ontimeout:d})});if(w(t.BlobData.type)||w(t.ContentTypeHeader)){let a=await t.BlobData.text();return await R(e,r,a)}return await z(e,t.BlobData)}var $=typeof unsafeWindow<"u"?unsafeWindow:window;async function G(e,r="NamuLink"){let n=e.Reflect.apply,t=[[/\( *\) *=> *{ *var *_0x[0-9a-z]+ *= *a0_0x[0-9a-f]+ *; *this\[ *_0x[a-z0-9]+\( *0x[0-9a-f]+ *\) *\]\(\); *}/,/\( *\) *=> *{ *var *_0x[0-9a-z]+ *= *a0_0x[0-9a-f]+ *; *this\[ *_0x[a-z0-9]+\( *0x[0-9a-f]+ *\) *\]\(\); *}/],[/\( *\) *=> *{ *var _0x[a-z0-9]+ *= *_0x[a-z0-9]+ *; *if *\( *this\[ *_0x[a-z0-9]+ *\( *0x[0-9a-f]+ *\) *\] *\) *return *clearTimeout/,/\( *0x[0-9a-f]+ *\) *\] *\) *, *void *\( *this\[ *_0x[a-z0-9]+\( *0x[0-9a-f]+ *\) *\] *= *void *\([x0-9a-f*+-]+ *\) *\) *; *this\[_0x[a-z0-9]+\( *0x[0-9a-f]+ *\) *\] *\(\) *;/]];e.setTimeout=new Proxy(e.setTimeout,{apply(g,i,f){let p=String(f[0]);return t.filter(E=>E.filter(o=>o.test(p)).length>=1).length===1?(console.debug(`[${r}]: setTimeout called for PowerLink Skeleton:`,f[0]),n(g,i,[()=>{},0])):n(g,i,f)}});let a=await M("#app",e.document);b(a,{QuietMs:75,EventName:"vue:settled",ChangeEventName:"vue:change",UrlChange:"vue:url-changed"});let c=H(e,new Worker(URL.createObjectURL(new Blob(['(()=>{var b=["\\uD30C\\uC6CC\\uB9C1\\uD06C","\\uAD11\\uACE0","\\uAD11\\uACE0\\uB4F1\\uB85D"],k=["Pretendard JP, sans-serif","Pretendard, sans-serif","system-ui, sans-serif","Apple SD Gothic Neo, sans-serif","Nanum Gothic, sans-serif","Noto Sans KR, sans-serif","Arial, sans-serif"],H=new Map;function T(t,n){return new OffscreenCanvas(Math.max(1,Math.floor(t)),Math.max(1,Math.floor(n)))}function C(t){let n=t.getContext("2d",{willReadFrequently:!0});if(!n)throw new Error("2D context unavailable");return n}function Y(t){let n=C(t),{width:a,height:e}=t,r=n.getImageData(0,0,a,e).data,o=new Uint8ClampedArray(a*e);for(let i=0,s=0;i<r.length;i+=4,s++){let l=r[i],h=r[i+1],g=r[i+2];o[s]=Math.round(.299*l+.587*h+.114*g)}return{Width:a,Height:e,Data:o}}function A(t){let n=new Uint32Array(256);for(let l=0;l<t.Data.length;l++)n[t.Data[l]]++;let a=t.Data.length,e=0;for(let l=0;l<256;l++)e+=l*n[l];let r=0,o=0,i=-1,s=127;for(let l=0;l<256;l++){if(o+=n[l],o===0)continue;let h=a-o;if(h===0)break;r+=l*n[l];let g=r/o,d=(e-r)/h,c=o*h*(g-d)*(g-d);c>i&&(i=c,s=l)}return s}function M(t){let n=A(t),a=0,e=0;for(let i=0;i<t.Data.length;i++)t.Data[i]<n?a++:e++;let r=a<e,o=new Uint8Array(t.Width*t.Height);for(let i=0;i<t.Data.length;i++){let s=r?t.Data[i]<n:t.Data[i]>n;o[i]=s?1:0}return{Width:t.Width,Height:t.Height,Data:o}}function O(t){let n=new Uint8Array(t.Width*t.Height);for(let a=1;a<t.Height-1;a++)for(let e=1;e<t.Width-1;e++){let r=1;for(let o=-1;o<=1&&r;o++)for(let i=-1;i<=1;i++)if(t.Data[(a+o)*t.Width+(e+i)]===0){r=0;break}n[a*t.Width+e]=r}return{Width:t.Width,Height:t.Height,Data:n}}function w(t){let n=new Uint8Array(t.Width*t.Height);for(let a=1;a<t.Height-1;a++)for(let e=1;e<t.Width-1;e++){let r=0;for(let o=-1;o<=1&&!r;o++)for(let i=-1;i<=1;i++)if(t.Data[(a+o)*t.Width+(e+i)]===1){r=1;break}n[a*t.Width+e]=r}return{Width:t.Width,Height:t.Height,Data:n}}function N(t){return w(O(w(t)))}function v(t,n=20){let a=new Uint8Array(t.Width*t.Height),e=[],r=new Int32Array(t.Width*t.Height),o=new Int32Array(t.Width*t.Height);for(let i=0;i<t.Height;i++)for(let s=0;s<t.Width;s++){let l=i*t.Width+s;if(a[l]||t.Data[l]===0)continue;let h=0,g=0;r[g]=s,o[g]=i,g++,a[l]=1;let d=s,c=i,u=s,f=i,X=0;for(;h<g;){let m=r[h],D=o[h];h++,X++,m<d&&(d=m),D<c&&(c=D),m>u&&(u=m),D>f&&(f=D);for(let I=-1;I<=1;I++)for(let y=-1;y<=1;y++){if(y===0&&I===0)continue;let W=m+y,B=D+I;if(W<0||B<0||W>=t.Width||B>=t.Height)continue;let x=B*t.Width+W;a[x]||t.Data[x]===0||(a[x]=1,r[g]=W,o[g]=B,g++)}}X>=n&&e.push({X:d,Y:c,Width:u-d+1,Height:f-c+1})}return e}function U(t,n=8,a=4){let e=[...t],r=!0;function o(i,s){let l=i.X+i.Width,h=i.Y+i.Height,g=s.X+s.Width,d=s.Y+s.Height;return!(l+n<s.X||g+n<i.X||h+a<s.Y||d+a<i.Y)}for(;r;){r=!1;t:for(let i=0;i<e.length;i++)for(let s=i+1;s<e.length;s++){if(!o(e[i],e[s]))continue;let l=e[i],h=e[s];e[i]={X:Math.min(l.X,h.X),Y:Math.min(l.Y,h.Y),Width:Math.max(l.X+l.Width,h.X+h.Width)-Math.min(l.X,h.X),Height:Math.max(l.Y+l.Height,h.Y+h.Height)-Math.min(l.Y,h.Y)},e.splice(s,1),r=!0;break t}}return e}function R(t,n){let a=new Uint8Array(n.Width*n.Height);for(let e=0;e<n.Height;e++)for(let r=0;r<n.Width;r++)a[e*n.Width+r]=t.Data[(n.Y+e)*t.Width+(n.X+r)];return{Width:n.Width,Height:n.Height,Data:a}}function E(t){let n=t.Width,a=t.Height,e=-1,r=-1;for(let o=0;o<t.Height;o++)for(let i=0;i<t.Width;i++)t.Data[o*t.Width+i]!==0&&(i<n&&(n=i),o<a&&(a=o),i>e&&(e=i),o>r&&(r=o));return e<n||r<a?{Width:1,Height:1,Data:new Uint8Array([0])}:R(t,{X:n,Y:a,Width:e-n+1,Height:r-a+1})}function P(t,n,a){let e=new Uint8Array(n*a);for(let r=0;r<a;r++)for(let o=0;o<n;o++){let i=Math.min(t.Width-1,Math.floor(o/n*t.Width)),s=Math.min(t.Height-1,Math.floor(r/a*t.Height));e[r*n+o]=t.Data[s*t.Width+i]}return{Width:n,Height:a,Data:e}}function p(t,n=64){let a=E(t),e=Math.max(a.Width,a.Height),r=new Uint8Array(e*e),o=Math.floor((e-a.Width)/2),i=Math.floor((e-a.Height)/2);for(let s=0;s<a.Height;s++)for(let l=0;l<a.Width;l++)r[(s+i)*e+(l+o)]=a.Data[s*a.Width+l];return P({Width:e,Height:e,Data:r},n,n)}function F(t,n){if(t.Width!==n.Width||t.Height!==n.Height)throw new Error("Image size mismatch");let a=0;for(let e=0;e<t.Data.length;e++)t.Data[e]!==n.Data[e]&&a++;return a/t.Data.length}function K(t,n){let a=`${t}__${n}`,e=H.get(a);if(e)return e;let r=256,o=96,i=T(r,o),s=C(i);s.fillStyle="white",s.fillRect(0,0,r,o);let l=Math.floor(o*.72);for(;l>8;){s.clearRect(0,0,r,o),s.fillStyle="white",s.fillRect(0,0,r,o),s.fillStyle="black",s.textAlign="center",s.textBaseline="middle",s.font=`700 ${l}px ${n}`;let g=s.measureText(t),d=g.width,c=(g.actualBoundingBoxAscent||l*.8)+(g.actualBoundingBoxDescent||l*.2);if(d<=r*.9&&c<=o*.9){s.fillText(t,r/2,o/2);let u=Y(i),f=p(M(u));return H.set(a,f),f}l--}s.font=`700 12px ${n}`,s.fillStyle="black",s.textAlign="center",s.textBaseline="middle",s.fillText(t,r/2,o/2);let h=p(M(Y(i)));return H.set(a,h),h}function V(t,n,a){let e=p(t),r=Number.POSITIVE_INFINITY;for(let o of a){let i=K(n,o),s=F(e,i);s<r&&(r=s)}return r}function z(t){let n=v(t,16);return U(n,10,6).filter(e=>{if(e.Width<8||e.Height<8)return!1;let r=e.Width/e.Height;return r>.5&&r<12})}async function $(t){let a=q(t.ImageData)?t.BackgroundCandidates:t.BackgroundCandidates.slice(0,1),e=t.FontCandidates??k,r=t.ScoreThreshold??.32,o=null;for(let i of a){let s=_(t.ImageData,i),l=G(s),h=N(M(l)),g=z(h);if(g.length!==0)for(let d of g){let c=R(h,d);for(let u of b){let f=V(c,u,e);(!o||f<o.Score)&&(o={Label:u,Score:f,Box:d})}}}return!o||o.Score>r?null:o}function G(t){let{width:n,height:a,data:e}=t,r=new Uint8ClampedArray(n*a);for(let o=0,i=0;o<e.length;o+=4,i++){let s=e[o],l=e[o+1],h=e[o+2];r[i]=Math.round(.299*s+.587*l+.114*h)}return{Width:n,Height:a,Data:r}}function q(t){let n=t.data;for(let a=3;a<n.length;a+=4)if(n[a]<255)return!0;return!1}function _(t,n){let a=T(t.width,t.height),e=C(a);return e.fillStyle=n,e.fillRect(0,0,t.width,t.height),e.putImageData(t,0,0),e.getImageData(0,0,t.width,t.height)}self.addEventListener("message",t=>{(async()=>{let n=t.data;if(!(!n||n.Kind!=="detect"))try{let a=await $(n),e={Kind:"detect-result",RequestId:n.RequestId,Result:a};self.postMessage(e)}catch(a){let e=a instanceof Error?a.message:String(a),r={Kind:"detect-error",RequestId:n.RequestId,Error:e};self.postMessage(r)}})()});})();\n'],{type:"application/javascript"}))));async function m(g){let i=[];for(let f of g){let p=[...f.querySelectorAll("*")].filter(o=>o instanceof HTMLElement).filter(o=>o instanceof HTMLImageElement||getComputedStyle(o).backgroundImage!=="none").filter(o=>parseFloat(getComputedStyle(o).getPropertyValue("width"))>=5&&parseFloat(getComputedStyle(o).getPropertyValue("height"))>=5).filter(o=>parseFloat(getComputedStyle(o).getPropertyValue("width"))<=50&&parseFloat(getComputedStyle(o).getPropertyValue("height"))<=50),E=0;for(let o of p)if(await c.DetectFromElement(o,{ScoreThreshold:.32})!==null&&(E+=1),E>=1){i.push(f);break}}return i}function h(g){let i=new Set([g]);for(let f=0;;f++){let p=[...i][f].parentElement;if(p===null)break;i.add(p)}return i}async function v(g){let i=[...document.querySelectorAll("#app div[class] div[class] ~ div[class]")].filter(o=>o instanceof HTMLElement);i=i.filter(o=>parseFloat(getComputedStyle(o).getPropertyValue("padding-top"))>=20||parseFloat(getComputedStyle(o).getPropertyValue("margin-top"))>=20||parseFloat(getComputedStyle(o).getPropertyValue("margin-bottom"))>=12.5),i=i.filter(o=>{let y=[...o.querySelectorAll("*")].filter(l=>l instanceof HTMLElement);return y.filter(l=>parseFloat(getComputedStyle(l).getPropertyValue("padding-top"))>=5&&parseFloat(getComputedStyle(l).getPropertyValue("border-bottom-width"))>=.1).length===1?!0:y.filter(l=>(l instanceof HTMLTableElement||l instanceof HTMLTableCellElement)&&parseFloat(getComputedStyle(l).getPropertyValue("padding-top"))>=5&&parseFloat(getComputedStyle(l).getPropertyValue("padding-bottom"))>=5).length>=2}),i=i.filter(o=>![...o.querySelectorAll("*")].filter(l=>l instanceof HTMLElement).some(l=>parseFloat(getComputedStyle(l).getPropertyValue("margin-bottom"))>=10&&parseFloat(getComputedStyle(l).getPropertyValue("padding-bottom"))>=1&&parseFloat(getComputedStyle(l).getPropertyValue("padding-top"))>=1&&parseFloat(getComputedStyle(l).getPropertyValue("border-top-width"))>=.25&&parseFloat(getComputedStyle(l).getPropertyValue("border-bottom-width"))>=.25)),i=i.filter(o=>{let y=[...o.querySelectorAll("*")].filter(l=>l instanceof HTMLElement);return y=y.filter(l=>parseFloat(getComputedStyle(l).getPropertyValue("padding-right"))>=10&&parseFloat(getComputedStyle(l).getPropertyValue("padding-bottom"))>=10),y=y.filter(l=>parseFloat(getComputedStyle(l).getPropertyValue("margin-left"))>=2.5),y.length===0}),i=i.filter(o=>o.getBoundingClientRect().width<500?!1:[...o.querySelectorAll("*[style]")].filter(l=>l instanceof HTMLElement&&l.style.length>0).filter(l=>{if(!(l instanceof HTMLElement))return!1;let F=getComputedStyle(l);return[...l.style].filter(C=>{let x=l.style.getPropertyValue(C).trim(),D=F.getPropertyValue(C).trim();return x!==D}).length<=1}).length<5),i=await m(i),i.forEach(o=>i.push(...new Set([...o.querySelectorAll("*")].filter(y=>y instanceof HTMLElement)))),i=[...new Set(i)];let f=i.filter(o=>parseFloat(getComputedStyle(o).getPropertyValue("padding-left"))>=5&&parseFloat(getComputedStyle(o).getPropertyValue("border-right-width"))>=.1);console.debug(`[${r}] ${g.type} RealTargeted`,f,g),f.forEach(o=>{o.style.setProperty("display","none","important")});let p=i.filter(o=>!(o instanceof HTMLElement)||!(o instanceof HTMLTableElement)?!1:[...o.querySelectorAll("*")].filter(l=>l instanceof HTMLElement).some(l=>parseFloat(getComputedStyle(l).getPropertyValue("padding-top"))>=5&&parseFloat(getComputedStyle(l).getPropertyValue("padding-bottom"))>=5));console.debug(`[${r}] ${g.type} RealTabletTargeted`,p,g),p.forEach(o=>{o.style.setProperty("display","none","important")});let E=new Set([...f,...p]);E.forEach(o=>{[...h(o)].filter(l=>l.innerText.trim().length===0).forEach(l=>E.add(l))}),console.debug(`[${r}] ${g.type} PlaceHolderCandidated`,E,g),[...E].forEach(o=>{o.style.setProperty("display","none","important")})}a.addEventListener("vue:settled",g=>v(g)),a.addEventListener("vue:url-changed",g=>setTimeout(()=>v(g),250)),["https://fonts.googleapis.com/css2?family=Nanum Gothic&display=swap"].forEach(g=>{let i=e.document.createElement("link");i.rel="stylesheet",i.href=g,e.document.head.appendChild(i)})}G($);})();
26
26
  /*!
27
27
  * @license MPL-2.0
28
28
  * This Source Code Form is subject to the terms of the Mozilla Public
package/dist/index.js CHANGED
@@ -33,10 +33,12 @@ export async function RunNamuLinkUserscript(BrowserWindow, UserscriptName = 'Nam
33
33
  const ArticleHTMLElement = await WaitForElement('#app', BrowserWindow.document);
34
34
  const EventName = 'vue:settled';
35
35
  const ChangeEventName = 'vue:change';
36
+ const UrlChangeEventName = 'vue:url-changed';
36
37
  AttachVueSettledEvents(ArticleHTMLElement, {
37
38
  QuietMs: 75,
38
39
  EventName: EventName,
39
- ChangeEventName: ChangeEventName
40
+ ChangeEventName: ChangeEventName,
41
+ UrlChange: UrlChangeEventName
40
42
  });
41
43
  const OCRInstance = CreateOcrWorkerClient(BrowserWindow, new Worker(URL.createObjectURL(new Blob([__OCR_WORKER_CODE__], { type: 'application/javascript' }))));
42
44
  async function ExecuteOCR(Targeted) {
@@ -102,6 +104,22 @@ export async function RunNamuLinkUserscript(BrowserWindow, UserscriptName = 'Nam
102
104
  Children = Children.filter(Child => parseFloat(getComputedStyle(Child).getPropertyValue('margin-left')) >= 2.5);
103
105
  return Children.length === 0;
104
106
  });
107
+ Targeted = Targeted.filter(Ele => {
108
+ if (Ele.getBoundingClientRect().width < 500)
109
+ return false;
110
+ let Children = [...Ele.querySelectorAll('*[style]')].filter(Child => Child instanceof HTMLElement && Child.style.length > 0);
111
+ return Children.filter(Child => {
112
+ if (!(Child instanceof HTMLElement))
113
+ return false;
114
+ const ComputedStyle = getComputedStyle(Child);
115
+ const MissingCount = [...Child.style].filter(Property => {
116
+ const InlineValue = Child.style.getPropertyValue(Property).trim();
117
+ const ComputedValue = ComputedStyle.getPropertyValue(Property).trim();
118
+ return InlineValue !== ComputedValue;
119
+ }).length;
120
+ return MissingCount <= 1;
121
+ }).length < 5;
122
+ });
105
123
  Targeted = await ExecuteOCR(Targeted);
106
124
  Targeted.forEach(Ele => Targeted.push(...new Set([...Ele.querySelectorAll('*')].filter(Child => Child instanceof HTMLElement))));
107
125
  Targeted = [...new Set(Targeted)];
@@ -132,6 +150,7 @@ export async function RunNamuLinkUserscript(BrowserWindow, UserscriptName = 'Nam
132
150
  });
133
151
  }
134
152
  ArticleHTMLElement.addEventListener('vue:settled', (EventParameter) => Handler(EventParameter));
153
+ ArticleHTMLElement.addEventListener('vue:url-changed', (EventParameter) => setTimeout(() => Handler(EventParameter), 250));
135
154
  // init Naver Nanum fonts
136
155
  const FontAddr = [
137
156
  'https://fonts.googleapis.com/css2?family=Nanum Gothic&display=swap',
@@ -2,6 +2,7 @@ export declare function AttachVueSettledEvents(TargetEl: HTMLElement, Options?:
2
2
  QuietMs?: number;
3
3
  EventName?: string;
4
4
  ChangeEventName?: string;
5
+ UrlChange?: string;
5
6
  }): {
6
7
  Disconnect(): void;
7
8
  };
@@ -2,6 +2,7 @@ export function AttachVueSettledEvents(TargetEl, Options = {}) {
2
2
  const QuietMs = Options.QuietMs ?? 120;
3
3
  const EventName = Options.EventName ?? 'vue:settled';
4
4
  const ChangeEventName = Options.ChangeEventName ?? 'vue:dom-changed';
5
+ const UrlChangeEventName = Options.UrlChange ?? 'vue:url-changed';
5
6
  if (!(TargetEl instanceof HTMLElement)) {
6
7
  throw new TypeError('TargetEl must be an HTMLElement');
7
8
  }
@@ -9,6 +10,7 @@ export function AttachVueSettledEvents(TargetEl, Options = {}) {
9
10
  let Seq = 0;
10
11
  let Destroyed = false;
11
12
  let LastMutationAt = performance.now();
13
+ let URLHistory = new URL(location.href);
12
14
  const EmitChange = (Mutations) => {
13
15
  TargetEl.dispatchEvent(new CustomEvent(ChangeEventName, {
14
16
  detail: {
@@ -37,6 +39,19 @@ export function AttachVueSettledEvents(TargetEl, Options = {}) {
37
39
  });
38
40
  });
39
41
  };
42
+ const EmitUrlChange = () => {
43
+ const NewURL = new URL(location.href);
44
+ if (NewURL.href !== URLHistory.href) {
45
+ URLHistory = NewURL;
46
+ TargetEl.dispatchEvent(new CustomEvent(UrlChangeEventName, {
47
+ detail: {
48
+ Seq,
49
+ At: performance.now(),
50
+ URL: NewURL,
51
+ },
52
+ }));
53
+ }
54
+ };
40
55
  const ArmSettledTimer = () => {
41
56
  clearTimeout(Timer);
42
57
  Timer = setTimeout(EmitSettled, QuietMs);
@@ -48,6 +63,7 @@ export function AttachVueSettledEvents(TargetEl, Options = {}) {
48
63
  if (Mutations.length >= 25) {
49
64
  ArmSettledTimer();
50
65
  }
66
+ EmitUrlChange();
51
67
  });
52
68
  Observer.observe(TargetEl, {
53
69
  subtree: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@filteringdev/namulink",
3
- "version": "20.1.3",
3
+ "version": "20.1.5-build.ba1badcc57e3",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "scripts": {