@filteringdev/namulink 20.1.2 → 20.1.4
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.
- package/dist/NamuLink.user.js +2 -2
- package/dist/index.js +14 -8
- package/dist/vuejsawait.d.ts +1 -0
- package/dist/vuejsawait.js +19 -1
- package/package.json +1 -1
package/dist/NamuLink.user.js
CHANGED
|
@@ -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.
|
|
11
|
+
// @version 20.1.4
|
|
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 y(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 u=-1,l=0,d=!1,m=performance.now(),o=i=>{e.dispatchEvent(new CustomEvent(a,{detail:{Seq:l,At:m,MutationCount:i.length,Mutations:i}}))},g=()=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{d||e.dispatchEvent(new CustomEvent(t,{detail:{Seq:l,QuietMs:n,SettledAt:performance.now(),ElapsedSinceLastMutation:performance.now()-m,Target:e}}))})})},p=()=>{clearTimeout(u),u=setTimeout(g,n)},f=new MutationObserver(i=>{l+=1,m=performance.now(),o(i),p()});return f.observe(e,{subtree:!0,childList:!0,attributes:!0,characterData:!0}),p(),{Disconnect(){d=!0,clearTimeout(u),f.disconnect(),e.dispatchEvent(new CustomEvent("vue:observer-disconnected",{detail:{Target:e}}))}}}function h(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 u=r.querySelector(e);u&&u instanceof HTMLElement&&(a.disconnect(),n(u))});a.observe(r,{subtree:!0,childList:!0,attributes:!0})})}function M(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 E(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 S(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 u=e.getComputedStyle(r);if(a(u.backgroundColor),a(u.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 L(e,r){if(r instanceof e.HTMLImageElement)return r.currentSrc||r.src||""||null;let n=e.getComputedStyle(r).backgroundImage;return M(n)}function T(e,r){let n=0,t=new Map;r.addEventListener("message",d=>{let m=d.data;if(!m||!("RequestId"in m))return;let o=t.get(m.RequestId);if(o){if(t.delete(m.RequestId),m.Kind==="detect-result"){o.Resolve(m.Result);return}o.Reject(new Error(m.Error))}});function a(d){let m=`ocr-${Date.now()}-${n++}`,o={Kind:"detect",RequestId:m,...d};return new Promise((g,p)=>{t.set(m,{Resolve:g,Reject:p}),r.postMessage(o)})}async function u(d,m){let o=L(e,d);if(!o)return null;let g=await C(e,d,o),p=E(e,d),f=S(e,d,p);return a({ImageData:g,BackgroundCandidates:f,FontCandidates:m?.FontCandidates,ScoreThreshold:m?.ScoreThreshold})}async function l(d){let m=await C(e,d.HostElement,d.SourceUrl),o=E(e,d.HostElement),g=S(e,d.HostElement,o);return a({ImageData:m,BackgroundCandidates:g,FontCandidates:d.FontCandidates,ScoreThreshold:d.ScoreThreshold})}return{DetectFromElement:u,DetectFromSource:l,Terminate(){for(let d of t.values())d.Reject(new Error("OCR worker terminated"));t.clear(),r.terminate()}}}function w(e){return/^data:image\/svg\+xml(?:[;,]|$)/i.test(e)}function P(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 R(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")?P(e,a):decodeURIComponent(a)}function F(e,r,n,t){let u=new e.DOMParser().parseFromString(r,"image/svg+xml");if(u.querySelector("parsererror"))throw new Error("Failed to parse SVG markup");let l=u.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(u)}function H(e){return e.complete&&e.naturalWidth>0?Promise.resolve():new Promise((r,n)=>{function t(){e.removeEventListener("load",a),e.removeEventListener("error",u)}function a(){t(),r()}function u(){t(),n(new Error("Failed to load SVG image"))}e.addEventListener("load",a),e.addEventListener("error",u)})}async function x(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 H(n),n}function v(e){return typeof e=="string"&&/^image\/svg\+xml(?:\s*;|$)/i.test(e)}function D(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 b(e,r,n){let{Width:t,Height:a}=D(e,r),u=F(e,n,t,a),l=e.URL.createObjectURL(new e.Blob([u],{type:"image/svg+xml"}));try{let d=await x(e,l),m=e.document.createElement("canvas");m.width=t,m.height=a;let o=m.getContext("2d",{willReadFrequently:!0});if(!o)throw new Error("2D context unavailable");return o.clearRect(0,0,t,a),o.drawImage(d,0,0,t,a),o.getImageData(0,0,t,a)}finally{e.URL.revokeObjectURL(l)}}async function k(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 C(e,r,n){if(w(n)){let a=R(e,n);return await b(e,r,a)}let t=await new Promise((a,u)=>{GM.xmlHttpRequest({url:n,method:"GET",responseType:"blob",onload:l=>{if(l.status<200||l.status>=300){u(new Error(`Failed to fetch image: ${l.status} ${l.statusText}`));return}let d=l.response;if(!(d instanceof Blob)){u(new Error("Failed to fetch image: invalid blob response"));return}let m=l.responseHeaders.match(/^content-type:\s*(.+)$/im),o=m?m[1].trim():null;a({BlobData:d,ContentTypeHeader:o})},onerror:u,ontimeout:u})});if(v(t.BlobData.type)||v(t.ContentTypeHeader)){let a=await t.BlobData.text();return await b(e,r,a)}return await k(e,t.BlobData)}var I=typeof unsafeWindow<"u"?unsafeWindow:window;async function q(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(o,g,p){let f=String(p[0]);return t.filter(i=>i.filter(c=>c.test(f)).length>=1).length===1?(console.debug(`[${r}]: setTimeout called for PowerLink Skeleton:`,p[0]),n(o,g,[()=>{},0])):n(o,g,p)}});let a=await h("#app",e.document);y(a,{QuietMs:250,EventName:"vue:settled",ChangeEventName:"vue:change"});let u=T(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 l(o){let g=[];for(let p of o){let f=[...p.querySelectorAll("*")].filter(c=>c instanceof HTMLElement).filter(c=>c instanceof HTMLImageElement||getComputedStyle(c).backgroundImage!=="none").filter(c=>parseFloat(getComputedStyle(c).getPropertyValue("width"))>=5&&parseFloat(getComputedStyle(c).getPropertyValue("height"))>=5).filter(c=>parseFloat(getComputedStyle(c).getPropertyValue("width"))<=50&&parseFloat(getComputedStyle(c).getPropertyValue("height"))<=50),i=0;for(let c of f)if(await u.DetectFromElement(c,{ScoreThreshold:.32})!==null&&(i+=1),i>=1){g.push(p);break}}return g}function d(o){let g=new Set([o]);for(let p=0;;p++){let f=[...g][p].parentElement;if(f===null)break;g.add(f)}return g}a.addEventListener("vue:settled",async()=>{let o=[...document.querySelectorAll("#app div[class] div[class] ~ div[class]")].filter(i=>i instanceof HTMLElement);o=o.filter(i=>parseFloat(getComputedStyle(i).getPropertyValue("padding-top"))>=20||parseFloat(getComputedStyle(i).getPropertyValue("margin-top"))>=20||parseFloat(getComputedStyle(i).getPropertyValue("margin-bottom"))>=12.5),o=o.filter(i=>{let c=[...i.querySelectorAll("*")].filter(s=>s instanceof HTMLElement);return c.filter(s=>parseFloat(getComputedStyle(s).getPropertyValue("padding-top"))>=5&&parseFloat(getComputedStyle(s).getPropertyValue("border-bottom-width"))>=.1).length===1?!0:c.filter(s=>(s instanceof HTMLTableElement||s instanceof HTMLTableCellElement)&&parseFloat(getComputedStyle(s).getPropertyValue("padding-top"))>=5&&parseFloat(getComputedStyle(s).getPropertyValue("padding-bottom"))>=5).length>=2}),o=o.filter(i=>![...i.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)),o=o.filter(i=>{let c=[...i.querySelectorAll("*")].filter(s=>s instanceof HTMLElement);return c=c.filter(s=>parseFloat(getComputedStyle(s).getPropertyValue("padding-right"))>=10&&parseFloat(getComputedStyle(s).getPropertyValue("padding-bottom"))>=10),c=c.filter(s=>parseFloat(getComputedStyle(s).getPropertyValue("margin-left"))>=2.5),c.length===0}),o=await l(o),o.forEach(i=>o.push(...new Set([...i.querySelectorAll("*")].filter(c=>c instanceof HTMLElement)))),o=[...new Set(o)];let g=o.filter(i=>parseFloat(getComputedStyle(i).getPropertyValue("padding-left"))>=5&&parseFloat(getComputedStyle(i).getPropertyValue("border-right-width"))>=.1);console.debug(`[${r}] vue:settled RealTargeted`,g),g.forEach(i=>{i.style.setProperty("display","none","important")});let p=o.filter(i=>!(i instanceof HTMLElement)||!(i instanceof HTMLTableElement)?!1:[...i.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}] vue:settled RealTabletTargeted`,p),p.forEach(i=>{i.style.setProperty("display","none","important")});let f=new Set([...g,...p]);f.forEach(i=>{[...d(i)].filter(s=>s.innerText.trim().length===0).forEach(s=>f.add(s))}),console.debug(`[${r}] vue:settled PlaceHolderCandidated`,f),[...f].forEach(i=>{i.style.setProperty("display","none","important")})}),["https://fonts.googleapis.com/css2?family=Nanum Gothic&display=swap"].forEach(o=>{let g=e.document.createElement("link");g.rel="stylesheet",g.href=o,e.document.head.appendChild(g)})}q(I);})();
|
|
25
|
+
(()=>{function C(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 i=-1,u=0,c=!1,m=performance.now(),y=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!==y.href&&(y=p,e.dispatchEvent(new CustomEvent(d,{detail:{Seq:u,At:performance.now(),URL:p}})))},l=()=>{clearTimeout(i),i=setTimeout(S,n)},f=new MutationObserver(p=>{u+=1,m=performance.now(),v(p),p.length>=25&&l(),g()});return f.observe(e,{subtree:!0,childList:!0,attributes:!0,characterData:!0}),l(),{Disconnect(){c=!0,clearTimeout(i),f.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 d=r.querySelector(e);d&&d instanceof HTMLElement&&(a.disconnect(),n(d))});a.observe(r,{subtree:!0,childList:!0,attributes:!0})})}function H(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(i){i&&(i==="transparent"||i==="rgba(0, 0, 0, 0)"||t.add(i))}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 i=e.getComputedStyle(e.document.body);a(i.backgroundColor),a(i.color)}return a("rgb(255, 255, 255)"),a("rgb(0, 0, 0)"),[...t]}function F(e,r){if(r instanceof e.HTMLImageElement)return r.currentSrc||r.src||""||null;let n=e.getComputedStyle(r).backgroundImage;return H(n)}function P(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((y,v)=>{t.set(c,{Resolve:y,Reject:v}),r.postMessage(m)})}async function d(u,c){let m=F(e,u);if(!m)return null;let y=await R(e,u,m),v=T(e,u),S=L(e,u,v);return a({ImageData:y,BackgroundCandidates:S,FontCandidates:c?.FontCandidates,ScoreThreshold:c?.ScoreThreshold})}async function i(u){let c=await R(e,u.HostElement,u.SourceUrl),m=T(e,u.HostElement),y=L(e,u.HostElement,m);return a({ImageData:c,BackgroundCandidates:y,FontCandidates:u.FontCandidates,ScoreThreshold:u.ScoreThreshold})}return{DetectFromElement:d,DetectFromSource:i,Terminate(){for(let u of t.values())u.Reject(new Error("OCR worker terminated"));t.clear(),r.terminate()}}}function x(e){return/^data:image\/svg\+xml(?:[;,]|$)/i.test(e)}function D(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 k(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")?D(e,a):decodeURIComponent(a)}function I(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 i=d.documentElement;if(!i||i.nodeName.toLowerCase()!=="svg")throw new Error("SVG root element not found");return i.getAttribute("xmlns")||i.setAttribute("xmlns","http://www.w3.org/2000/svg"),i.getAttribute("width")||i.setAttribute("width",String(n)),i.getAttribute("height")||i.setAttribute("height",String(t)),new e.XMLSerializer().serializeToString(d)}function q(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 A(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 q(n),n}function M(e){return typeof e=="string"&&/^image\/svg\+xml(?:\s*;|$)/i.test(e)}function V(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 w(e,r,n){let{Width:t,Height:a}=V(e,r),d=I(e,n,t,a),i=e.URL.createObjectURL(new e.Blob([d],{type:"image/svg+xml"}));try{let u=await A(e,i),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(i)}}async function U(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 R(e,r,n){if(x(n)){let a=k(e,n);return await w(e,r,a)}let t=await new Promise((a,d)=>{GM.xmlHttpRequest({url:n,method:"GET",responseType:"blob",onload:i=>{if(i.status<200||i.status>=300){d(new Error(`Failed to fetch image: ${i.status} ${i.statusText}`));return}let u=i.response;if(!(u instanceof Blob)){d(new Error("Failed to fetch image: invalid blob response"));return}let c=i.responseHeaders.match(/^content-type:\s*(.+)$/im),m=c?c[1].trim():null;a({BlobData:u,ContentTypeHeader:m})},onerror:d,ontimeout:d})});if(M(t.BlobData.type)||M(t.ContentTypeHeader)){let a=await t.BlobData.text();return await w(e,r,a)}return await U(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(g,l,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,l,[()=>{},0])):n(g,l,f)}});let a=await b("#app",e.document);C(a,{QuietMs:75,EventName:"vue:settled",ChangeEventName:"vue:change",UrlChange:"vue:url-changed"});let c=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 m(g){let l=[];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){l.push(f);break}}return l}function y(g){let l=new Set([g]);for(let f=0;;f++){let p=[...l][f].parentElement;if(p===null)break;l.add(p)}return l}async function v(g){let l=[...document.querySelectorAll("#app div[class] div[class] ~ div[class]")].filter(o=>o instanceof HTMLElement);l=l.filter(o=>parseFloat(getComputedStyle(o).getPropertyValue("padding-top"))>=20||parseFloat(getComputedStyle(o).getPropertyValue("margin-top"))>=20||parseFloat(getComputedStyle(o).getPropertyValue("margin-bottom"))>=12.5),l=l.filter(o=>{let h=[...o.querySelectorAll("*")].filter(s=>s instanceof HTMLElement);return h.filter(s=>parseFloat(getComputedStyle(s).getPropertyValue("padding-top"))>=5&&parseFloat(getComputedStyle(s).getPropertyValue("border-bottom-width"))>=.1).length===1?!0:h.filter(s=>(s instanceof HTMLTableElement||s instanceof HTMLTableCellElement)&&parseFloat(getComputedStyle(s).getPropertyValue("padding-top"))>=5&&parseFloat(getComputedStyle(s).getPropertyValue("padding-bottom"))>=5).length>=2}),l=l.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)),l=l.filter(o=>{let h=[...o.querySelectorAll("*")].filter(s=>s instanceof HTMLElement);return h=h.filter(s=>parseFloat(getComputedStyle(s).getPropertyValue("padding-right"))>=10&&parseFloat(getComputedStyle(s).getPropertyValue("padding-bottom"))>=10),h=h.filter(s=>parseFloat(getComputedStyle(s).getPropertyValue("margin-left"))>=2.5),h.length===0}),l=await m(l),l.forEach(o=>l.push(...new Set([...o.querySelectorAll("*")].filter(h=>h instanceof HTMLElement)))),l=[...new Set(l)];let f=l.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=l.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}] ${g.type} RealTabletTargeted`,p,g),p.forEach(o=>{o.style.setProperty("display","none","important")});let E=new Set([...f,...p]);E.forEach(o=>{[...y(o)].filter(s=>s.innerText.trim().length===0).forEach(s=>E.add(s))}),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 l=e.document.createElement("link");l.rel="stylesheet",l.href=g,e.document.head.appendChild(l)})}O(_);})();
|
|
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
|
@@ -31,10 +31,14 @@ export async function RunNamuLinkUserscript(BrowserWindow, UserscriptName = 'Nam
|
|
|
31
31
|
}
|
|
32
32
|
});
|
|
33
33
|
const ArticleHTMLElement = await WaitForElement('#app', BrowserWindow.document);
|
|
34
|
+
const EventName = 'vue:settled';
|
|
35
|
+
const ChangeEventName = 'vue:change';
|
|
36
|
+
const UrlChangeEventName = 'vue:url-changed';
|
|
34
37
|
AttachVueSettledEvents(ArticleHTMLElement, {
|
|
35
|
-
QuietMs:
|
|
36
|
-
EventName:
|
|
37
|
-
ChangeEventName:
|
|
38
|
+
QuietMs: 75,
|
|
39
|
+
EventName: EventName,
|
|
40
|
+
ChangeEventName: ChangeEventName,
|
|
41
|
+
UrlChange: UrlChangeEventName
|
|
38
42
|
});
|
|
39
43
|
const OCRInstance = CreateOcrWorkerClient(BrowserWindow, new Worker(URL.createObjectURL(new Blob([__OCR_WORKER_CODE__], { type: 'application/javascript' }))));
|
|
40
44
|
async function ExecuteOCR(Targeted) {
|
|
@@ -72,7 +76,7 @@ export async function RunNamuLinkUserscript(BrowserWindow, UserscriptName = 'Nam
|
|
|
72
76
|
}
|
|
73
77
|
return SetHTMLElement;
|
|
74
78
|
}
|
|
75
|
-
|
|
79
|
+
async function Handler(EventParameter) {
|
|
76
80
|
let Targeted = [...document.querySelectorAll('#app div[class] div[class] ~ div[class]')].filter(Ele => Ele instanceof HTMLElement);
|
|
77
81
|
Targeted = Targeted.filter(Ele => parseFloat(getComputedStyle(Ele).getPropertyValue('padding-top')) >= 20 ||
|
|
78
82
|
parseFloat(getComputedStyle(Ele).getPropertyValue('margin-top')) >= 20 ||
|
|
@@ -104,7 +108,7 @@ export async function RunNamuLinkUserscript(BrowserWindow, UserscriptName = 'Nam
|
|
|
104
108
|
Targeted.forEach(Ele => Targeted.push(...new Set([...Ele.querySelectorAll('*')].filter(Child => Child instanceof HTMLElement))));
|
|
105
109
|
Targeted = [...new Set(Targeted)];
|
|
106
110
|
let RealTargeted = Targeted.filter(Ele => parseFloat(getComputedStyle(Ele).getPropertyValue('padding-left')) >= 5 && parseFloat(getComputedStyle(Ele).getPropertyValue('border-right-width')) >= 0.1);
|
|
107
|
-
console.debug(`[${UserscriptName}]
|
|
111
|
+
console.debug(`[${UserscriptName}] ${EventParameter.type} RealTargeted`, RealTargeted, EventParameter);
|
|
108
112
|
RealTargeted.forEach(Ele => {
|
|
109
113
|
Ele.style.setProperty('display', 'none', 'important');
|
|
110
114
|
});
|
|
@@ -114,7 +118,7 @@ export async function RunNamuLinkUserscript(BrowserWindow, UserscriptName = 'Nam
|
|
|
114
118
|
let Children = [...Ele.querySelectorAll('*')].filter(Child => Child instanceof HTMLElement);
|
|
115
119
|
return Children.some(Child => parseFloat(getComputedStyle(Child).getPropertyValue('padding-top')) >= 5 && parseFloat(getComputedStyle(Child).getPropertyValue('padding-bottom')) >= 5);
|
|
116
120
|
});
|
|
117
|
-
console.debug(`[${UserscriptName}]
|
|
121
|
+
console.debug(`[${UserscriptName}] ${EventParameter.type} RealTabletTargeted`, RealTabletTargeted, EventParameter);
|
|
118
122
|
RealTabletTargeted.forEach(Ele => {
|
|
119
123
|
Ele.style.setProperty('display', 'none', 'important');
|
|
120
124
|
});
|
|
@@ -124,11 +128,13 @@ export async function RunNamuLinkUserscript(BrowserWindow, UserscriptName = 'Nam
|
|
|
124
128
|
let Parents = [...AllParents(PlaceHolder)].filter(Ele => Ele.innerText.trim().length === 0);
|
|
125
129
|
Parents.forEach(Ele => PlaceHolderCandidated.add(Ele));
|
|
126
130
|
});
|
|
127
|
-
console.debug(`[${UserscriptName}]
|
|
131
|
+
console.debug(`[${UserscriptName}] ${EventParameter.type} PlaceHolderCandidated`, PlaceHolderCandidated, EventParameter);
|
|
128
132
|
[...PlaceHolderCandidated].forEach(Ele => {
|
|
129
133
|
Ele.style.setProperty('display', 'none', 'important');
|
|
130
134
|
});
|
|
131
|
-
}
|
|
135
|
+
}
|
|
136
|
+
ArticleHTMLElement.addEventListener('vue:settled', (EventParameter) => Handler(EventParameter));
|
|
137
|
+
ArticleHTMLElement.addEventListener('vue:url-changed', (EventParameter) => setTimeout(() => Handler(EventParameter), 250));
|
|
132
138
|
// init Naver Nanum fonts
|
|
133
139
|
const FontAddr = [
|
|
134
140
|
'https://fonts.googleapis.com/css2?family=Nanum Gothic&display=swap',
|
package/dist/vuejsawait.d.ts
CHANGED
package/dist/vuejsawait.js
CHANGED
|
@@ -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);
|
|
@@ -45,7 +60,10 @@ export function AttachVueSettledEvents(TargetEl, Options = {}) {
|
|
|
45
60
|
Seq += 1;
|
|
46
61
|
LastMutationAt = performance.now();
|
|
47
62
|
EmitChange(Mutations);
|
|
48
|
-
|
|
63
|
+
if (Mutations.length >= 25) {
|
|
64
|
+
ArmSettledTimer();
|
|
65
|
+
}
|
|
66
|
+
EmitUrlChange();
|
|
49
67
|
});
|
|
50
68
|
Observer.observe(TargetEl, {
|
|
51
69
|
subtree: true,
|