From d438bd35e8b2446099b209e1ed4b93a0b5a24d5e Mon Sep 17 00:00:00 2001 From: PiQuark6046 Date: Wed, 14 Feb 2024 03:57:40 +0000 Subject: [PATCH] fix: hidden document history (#35) * fix: hidden document history * chore: update version --- NamuLink.user.js | 4 ++-- package.json | 2 +- sources/banner.txt | 2 +- sources/src/index.ts | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/NamuLink.user.js b/NamuLink.user.js index ecd34d5..47a1489 100644 --- a/NamuLink.user.js +++ b/NamuLink.user.js @@ -8,7 +8,7 @@ // @downloadURL https://cdn.jsdelivr.net/gh/List-KR/NamuLink@latest/NamuLink.user.js // @license MIT // -// @version 3.1.0 +// @version 3.1.1 // @author PiQuark6046 and contributors // // @match https://namu.wiki/* @@ -22,4 +22,4 @@ // ==/UserScript== // Used libraries: // - Superstruct https://github.com/ianstormtaylor/superstruct -(()=>{var _=Object.defineProperty;var W=(e,n)=>{for(var t in n)_(e,t,{get:n[t],enumerable:!0})};var b={};W(b,{Struct:()=>f,StructError:()=>k,any:()=>ee,array:()=>ne,assert:()=>A,assign:()=>B,bigint:()=>te,boolean:()=>re,coerce:()=>N,create:()=>T,date:()=>ie,defaulted:()=>we,define:()=>p,deprecated:()=>G,dynamic:()=>K,empty:()=>$e,enums:()=>oe,func:()=>ce,instance:()=>se,integer:()=>fe,intersection:()=>ae,is:()=>L,lazy:()=>Q,literal:()=>de,map:()=>ue,mask:()=>O,max:()=>ke,min:()=>je,never:()=>M,nonempty:()=>xe,nullable:()=>le,number:()=>pe,object:()=>g,omit:()=>U,optional:()=>C,partial:()=>X,pattern:()=>Le,pick:()=>Y,record:()=>ye,refine:()=>h,regexp:()=>me,set:()=>he,size:()=>Me,string:()=>v,struct:()=>Z,trimmed:()=>ge,tuple:()=>be,type:()=>S,union:()=>Ee,unknown:()=>z,validate:()=>E});var k=class extends TypeError{constructor(n,t){let r,{message:i,explanation:o,...c}=n,{path:s}=n,d=s.length===0?i:`At path: ${s.join(".")} -- ${i}`;super(o??d),o!=null&&(this.cause=d),Object.assign(this,c),this.name=this.constructor.name,this.failures=()=>r??(r=[n,...t()])}};function R(e){return m(e)&&typeof e[Symbol.iterator]=="function"}function m(e){return typeof e=="object"&&e!=null}function H(e){if(Object.prototype.toString.call(e)!=="[object Object]")return!1;let n=Object.getPrototypeOf(e);return n===null||n===Object.prototype}function u(e){return typeof e=="symbol"?e.toString():typeof e=="string"?JSON.stringify(e):`${e}`}function V(e){let{done:n,value:t}=e.next();return n?void 0:t}function J(e,n,t,r){if(e===!0)return;e===!1?e={}:typeof e=="string"&&(e={message:e});let{path:i,branch:o}=n,{type:c}=t,{refinement:s,message:d=`Expected a value of type \`${c}\`${s?` with refinement \`${s}\``:""}, but received: \`${u(r)}\``}=e;return{value:r,type:c,refinement:s,key:i[i.length-1],path:i,branch:o,...e,message:d}}function*j(e,n,t,r){R(e)||(e=[e]);for(let i of e){let o=J(i,n,t,r);o&&(yield o)}}function*x(e,n,t={}){let{path:r=[],branch:i=[e],coerce:o=!1,mask:c=!1}=t,s={path:r,branch:i};if(o&&(e=n.coercer(e,s),c&&n.type!=="type"&&m(n.schema)&&m(e)&&!Array.isArray(e)))for(let a in e)n.schema[a]===void 0&&delete e[a];let d="valid";for(let a of n.validator(e,s))a.explanation=t.message,d="not_valid",yield[a,void 0];for(let[a,y,F]of n.entries(e,s)){let D=x(y,F,{path:a===void 0?r:[...r,a],branch:a===void 0?i:[...i,y],coerce:o,mask:c,message:t.message});for(let $ of D)$[0]?(d=$[0].refinement!=null?"not_refined":"not_valid",yield[$[0],void 0]):o&&(y=$[1],a===void 0?e=y:e instanceof Map?e.set(a,y):e instanceof Set?e.add(y):m(e)&&(y!==void 0||a in e)&&(e[a]=y))}if(d!=="not_valid")for(let a of n.refiner(e,s))a.explanation=t.message,d="not_refined",yield[a,void 0];d==="valid"&&(yield[void 0,e])}var f=class{constructor(n){let{type:t,schema:r,validator:i,refiner:o,coercer:c=d=>d,entries:s=function*(){}}=n;this.type=t,this.schema=r,this.entries=s,this.coercer=c,i?this.validator=(d,a)=>{let y=i(d,a);return j(y,a,this,d)}:this.validator=()=>[],o?this.refiner=(d,a)=>{let y=o(d,a);return j(y,a,this,d)}:this.refiner=()=>[]}assert(n,t){return A(n,this,t)}create(n,t){return T(n,this,t)}is(n){return L(n,this)}mask(n,t){return O(n,this,t)}validate(n,t={}){return E(n,this,t)}};function A(e,n,t){let r=E(e,n,{message:t});if(r[0])throw r[0]}function T(e,n,t){let r=E(e,n,{coerce:!0,message:t});if(r[0])throw r[0];return r[1]}function O(e,n,t){let r=E(e,n,{coerce:!0,mask:!0,message:t});if(r[0])throw r[0];return r[1]}function L(e,n){return!E(e,n)[0]}function E(e,n,t={}){let r=x(e,n,t),i=V(r);return i[0]?[new k(i[0],function*(){for(let c of r)c[0]&&(yield c[0])}),void 0]:[void 0,i[1]]}function B(...e){let n=e[0].type==="type",t=e.map(i=>i.schema),r=Object.assign({},...t);return n?S(r):g(r)}function p(e,n){return new f({type:e,schema:null,validator:n})}function G(e,n){return new f({...e,refiner:(t,r)=>t===void 0||e.refiner(t,r),validator(t,r){return t===void 0?!0:(n(t,r),e.validator(t,r))}})}function K(e){return new f({type:"dynamic",schema:null,*entries(n,t){yield*e(n,t).entries(n,t)},validator(n,t){return e(n,t).validator(n,t)},coercer(n,t){return e(n,t).coercer(n,t)},refiner(n,t){return e(n,t).refiner(n,t)}})}function Q(e){let n;return new f({type:"lazy",schema:null,*entries(t,r){n??(n=e()),yield*n.entries(t,r)},validator(t,r){return n??(n=e()),n.validator(t,r)},coercer(t,r){return n??(n=e()),n.coercer(t,r)},refiner(t,r){return n??(n=e()),n.refiner(t,r)}})}function U(e,n){let{schema:t}=e,r={...t};for(let i of n)delete r[i];switch(e.type){case"type":return S(r);default:return g(r)}}function X(e){let n=e instanceof f?{...e.schema}:{...e};for(let t in n)n[t]=C(n[t]);return g(n)}function Y(e,n){let{schema:t}=e,r={};for(let i of n)r[i]=t[i];return g(r)}function Z(e,n){return console.warn("superstruct@0.11 - The `struct` helper has been renamed to `define`."),p(e,n)}function ee(){return p("any",()=>!0)}function ne(e){return new f({type:"array",schema:e,*entries(n){if(e&&Array.isArray(n))for(let[t,r]of n.entries())yield[t,r,e]},coercer(n){return Array.isArray(n)?n.slice():n},validator(n){return Array.isArray(n)||`Expected an array value, but received: ${u(n)}`}})}function te(){return p("bigint",e=>typeof e=="bigint")}function re(){return p("boolean",e=>typeof e=="boolean")}function ie(){return p("date",e=>e instanceof Date&&!isNaN(e.getTime())||`Expected a valid \`Date\` object, but received: ${u(e)}`)}function oe(e){let n={},t=e.map(r=>u(r)).join();for(let r of e)n[r]=r;return new f({type:"enums",schema:n,validator(r){return e.includes(r)||`Expected one of \`${t}\`, but received: ${u(r)}`}})}function ce(){return p("func",e=>typeof e=="function"||`Expected a function, but received: ${u(e)}`)}function se(e){return p("instance",n=>n instanceof e||`Expected a \`${e.name}\` instance, but received: ${u(n)}`)}function fe(){return p("integer",e=>typeof e=="number"&&!isNaN(e)&&Number.isInteger(e)||`Expected an integer, but received: ${u(e)}`)}function ae(e){return new f({type:"intersection",schema:null,*entries(n,t){for(let r of e)yield*r.entries(n,t)},*validator(n,t){for(let r of e)yield*r.validator(n,t)},*refiner(n,t){for(let r of e)yield*r.refiner(n,t)}})}function de(e){let n=u(e),t=typeof e;return new f({type:"literal",schema:t==="string"||t==="number"||t==="boolean"?e:null,validator(r){return r===e||`Expected the literal \`${n}\`, but received: ${u(r)}`}})}function ue(e,n){return new f({type:"map",schema:null,*entries(t){if(e&&n&&t instanceof Map)for(let[r,i]of t.entries())yield[r,r,e],yield[r,i,n]},coercer(t){return t instanceof Map?new Map(t):t},validator(t){return t instanceof Map||`Expected a \`Map\` object, but received: ${u(t)}`}})}function M(){return p("never",()=>!1)}function le(e){return new f({...e,validator:(n,t)=>n===null||e.validator(n,t),refiner:(n,t)=>n===null||e.refiner(n,t)})}function pe(){return p("number",e=>typeof e=="number"&&!isNaN(e)||`Expected a number, but received: ${u(e)}`)}function g(e){let n=e?Object.keys(e):[],t=M();return new f({type:"object",schema:e||null,*entries(r){if(e&&m(r)){let i=new Set(Object.keys(r));for(let o of n)i.delete(o),yield[o,r[o],e[o]];for(let o of i)yield[o,r[o],t]}},validator(r){return m(r)||`Expected an object, but received: ${u(r)}`},coercer(r){return m(r)?{...r}:r}})}function C(e){return new f({...e,validator:(n,t)=>n===void 0||e.validator(n,t),refiner:(n,t)=>n===void 0||e.refiner(n,t)})}function ye(e,n){return new f({type:"record",schema:null,*entries(t){if(m(t))for(let r in t){let i=t[r];yield[r,r,e],yield[r,i,n]}},validator(t){return m(t)||`Expected an object, but received: ${u(t)}`}})}function me(){return p("regexp",e=>e instanceof RegExp)}function he(e){return new f({type:"set",schema:null,*entries(n){if(e&&n instanceof Set)for(let t of n)yield[t,t,e]},coercer(n){return n instanceof Set?new Set(n):n},validator(n){return n instanceof Set||`Expected a \`Set\` object, but received: ${u(n)}`}})}function v(){return p("string",e=>typeof e=="string"||`Expected a string, but received: ${u(e)}`)}function be(e){let n=M();return new f({type:"tuple",schema:null,*entries(t){if(Array.isArray(t)){let r=Math.max(e.length,t.length);for(let i=0;it.type).join(" | ");return new f({type:"union",schema:null,coercer(t){for(let r of e){let[i,o]=r.validate(t,{coerce:!0});if(!i)return o}return t},validator(t,r){let i=[];for(let o of e){let[...c]=x(t,o,r),[s]=c;if(s[0])for(let[d]of c)d&&i.push(d);else return[]}return[`Expected the value to satisfy a union of \`${n}\`, but received: ${u(t)}`,...i]}})}function z(){return p("unknown",()=>!0)}function N(e,n,t){return new f({...e,coercer:(r,i)=>L(r,n)?e.coercer(t(r,i),i):e.coercer(r,i)})}function we(e,n,t={}){return N(e,z(),r=>{let i=typeof n=="function"?n():n;if(r===void 0)return i;if(!t.strict&&H(r)&&H(i)){let o={...r},c=!1;for(let s in i)o[s]===void 0&&(o[s]=i[s],c=!0);if(c)return o}return r})}function ge(e){return N(e,v(),n=>n.trim())}function $e(e){return h(e,"empty",n=>{let t=P(n);return t===0||`Expected an empty ${e.type} but received one with a size of \`${t}\``})}function P(e){return e instanceof Map||e instanceof Set?e.size:e.length}function ke(e,n,t={}){let{exclusive:r}=t;return h(e,"max",i=>r?ir?i>n:i>=n||`Expected a ${e.type} greater than ${r?"":"or equal to "}${n} but received \`${i}\``)}function xe(e){return h(e,"nonempty",n=>P(n)>0||`Expected a nonempty ${e.type} but received an empty one`)}function Le(e,n){return h(e,"pattern",t=>n.test(t)||`Expected a ${e.type} matching \`/${n.source}/\` but received "${t}"`)}function Me(e,n,t=n){let r=`Expected a ${e.type}`,i=n===t?`of \`${n}\``:`between \`${n}\` and \`${t}\``;return h(e,"size",o=>{if(typeof o=="number"||o instanceof Date)return n<=o&&o<=t||`${r} ${i} but received \`${o}\``;if(o instanceof Map||o instanceof Set){let{size:c}=o;return n<=c&&c<=t||`${r} with a size ${i} but received one with a size of \`${c}\``}else{let{length:c}=o;return n<=c&&c<=t||`${r} with a length ${i} but received one with a length of \`${c}\``}})}function h(e,n,t){return new f({...e,*refiner(r,i){yield*e.refiner(r,i);let o=t(r,i),c=j(o,i,e,r);for(let s of c)yield{...s,refinement:n}}})}var l=typeof unsafeWindow<"u"?unsafeWindow:window,Se=new Event("namuwikinavigationwithadvert"),I=new Event("namuwikinavigation"),Ne=new Event("namuwikifristvisit"),He=e=>{if(Array.isArray(e)){if(e.toString().includes("//adcr.naver.com/adcr?"))return!0}else for(let n of Object.keys(e))try{if(typeof e[n]=="string"&&e[n].includes("//adcr.naver.com/adcr?"))return!0}catch{}return!1},Ae=e=>!Number.isNaN(Number(e)),Te=b.object({enable_ads:b.define("IsFakeNumber",Ae)}),Oe=e=>typeof e[0]<"u"&&typeof e[0]=="object"&&b.validate(e,Te)&&He(e[0]);l.Object.defineProperty=new Proxy(l.Object.defineProperty,{apply(e,n,t){Oe(t)?console.debug("[NamuLink:index]: Object.defineProperty:",[e,n,t]):Reflect.apply(e,n,t)}});l.TextDecoder.prototype.decode=new Proxy(l.TextDecoder.prototype.decode,{apply(e,n,t){let r=Reflect.apply(e,n,t);return r.includes("//adcr.naver.com/adcr?")?(console.debug("[NamuLink:index]: TextDecoder.prototype.decode:",[e,n,t]),l.dispatchEvent(I),l.dispatchEvent(Se),new Error):(r==="enable_ads"&&l.dispatchEvent(I),r)}});l.Array.prototype.push=new Proxy(l.Array.prototype.push,{apply(e,n,t){t.toString().includes("//adcr.naver.com/adcr?")?(console.debug("[NamuLink:index]: Array.prototype.push:",[e,n,t]),l.dispatchEvent(Ne)):Reflect.apply(e,n,t)}});var w=[],Ce=e=>{w.push(...e),e.forEach(n=>{n.style.setProperty("display","none","important")})},ve=()=>{console.debug("[NamuLink:index]: ShowElements:",w),w=w.filter(e=>e.parentElement!==null),w.forEach(e=>{e.style.removeProperty("display")}),w=[]},q=()=>{let e=Array.from(l.document.querySelectorAll('article div:not([class*=" "]):has(h1)~ div * ~ div[class]'));e.push(...Array.from(l.document.querySelectorAll('article div:not([class*=" "]):has(h1) ~ *')));let n=e.filter(i=>i instanceof HTMLElement);var t=[];let r=[];t=n.filter(i=>i.innerText.length<25),t=t.filter(i=>Array.from(i.querySelectorAll("*")).filter(s=>s instanceof HTMLElement).some(s=>Number(getComputedStyle(s).getPropertyValue("margin-bottom").replace(/px$/,""))>=4)),t=t.filter(i=>Array.from(i.querySelectorAll("*")).filter(c=>c instanceof HTMLIFrameElement).length===0),r.push(...t.filter(i=>Array.from(i.querySelectorAll("*")).filter(s=>s instanceof HTMLElement).filter(s=>getComputedStyle(s).getPropertyValue("animation-iteration-count")==="infinite").length>=6)),r.push(...t.filter(i=>Array.from(i.querySelectorAll("*")).filter(s=>s instanceof HTMLElement).some(s=>Number(getComputedStyle(s).getPropertyValue("margin-bottom").replace(/px$/,""))>=10))),console.debug("[NamuLink:index]: HideLeftoverElement:",r),Ce(r)};l.addEventListener("namuwikinavigationwithadvert",q);l.addEventListener("namuwikifristvisit",q);l.addEventListener("namuwikinavigation",ve);})(); +(()=>{var _=Object.defineProperty;var W=(e,n)=>{for(var t in n)_(e,t,{get:n[t],enumerable:!0})};var b={};W(b,{Struct:()=>f,StructError:()=>k,any:()=>ee,array:()=>ne,assert:()=>A,assign:()=>U,bigint:()=>te,boolean:()=>re,coerce:()=>N,create:()=>T,date:()=>ie,defaulted:()=>we,define:()=>p,deprecated:()=>B,dynamic:()=>G,empty:()=>$e,enums:()=>oe,func:()=>ce,instance:()=>se,integer:()=>fe,intersection:()=>ae,is:()=>L,lazy:()=>K,literal:()=>de,map:()=>ue,mask:()=>O,max:()=>ke,min:()=>je,never:()=>M,nonempty:()=>xe,nullable:()=>le,number:()=>pe,object:()=>g,omit:()=>Q,optional:()=>C,partial:()=>X,pattern:()=>Le,pick:()=>Y,record:()=>ye,refine:()=>h,regexp:()=>me,set:()=>he,size:()=>Me,string:()=>v,struct:()=>Z,trimmed:()=>ge,tuple:()=>be,type:()=>S,union:()=>Ee,unknown:()=>z,validate:()=>E});var k=class extends TypeError{constructor(n,t){let r,{message:i,explanation:o,...c}=n,{path:s}=n,d=s.length===0?i:`At path: ${s.join(".")} -- ${i}`;super(o??d),o!=null&&(this.cause=d),Object.assign(this,c),this.name=this.constructor.name,this.failures=()=>r??(r=[n,...t()])}};function R(e){return m(e)&&typeof e[Symbol.iterator]=="function"}function m(e){return typeof e=="object"&&e!=null}function H(e){if(Object.prototype.toString.call(e)!=="[object Object]")return!1;let n=Object.getPrototypeOf(e);return n===null||n===Object.prototype}function u(e){return typeof e=="symbol"?e.toString():typeof e=="string"?JSON.stringify(e):`${e}`}function V(e){let{done:n,value:t}=e.next();return n?void 0:t}function J(e,n,t,r){if(e===!0)return;e===!1?e={}:typeof e=="string"&&(e={message:e});let{path:i,branch:o}=n,{type:c}=t,{refinement:s,message:d=`Expected a value of type \`${c}\`${s?` with refinement \`${s}\``:""}, but received: \`${u(r)}\``}=e;return{value:r,type:c,refinement:s,key:i[i.length-1],path:i,branch:o,...e,message:d}}function*j(e,n,t,r){R(e)||(e=[e]);for(let i of e){let o=J(i,n,t,r);o&&(yield o)}}function*x(e,n,t={}){let{path:r=[],branch:i=[e],coerce:o=!1,mask:c=!1}=t,s={path:r,branch:i};if(o&&(e=n.coercer(e,s),c&&n.type!=="type"&&m(n.schema)&&m(e)&&!Array.isArray(e)))for(let a in e)n.schema[a]===void 0&&delete e[a];let d="valid";for(let a of n.validator(e,s))a.explanation=t.message,d="not_valid",yield[a,void 0];for(let[a,y,F]of n.entries(e,s)){let D=x(y,F,{path:a===void 0?r:[...r,a],branch:a===void 0?i:[...i,y],coerce:o,mask:c,message:t.message});for(let $ of D)$[0]?(d=$[0].refinement!=null?"not_refined":"not_valid",yield[$[0],void 0]):o&&(y=$[1],a===void 0?e=y:e instanceof Map?e.set(a,y):e instanceof Set?e.add(y):m(e)&&(y!==void 0||a in e)&&(e[a]=y))}if(d!=="not_valid")for(let a of n.refiner(e,s))a.explanation=t.message,d="not_refined",yield[a,void 0];d==="valid"&&(yield[void 0,e])}var f=class{constructor(n){let{type:t,schema:r,validator:i,refiner:o,coercer:c=d=>d,entries:s=function*(){}}=n;this.type=t,this.schema=r,this.entries=s,this.coercer=c,i?this.validator=(d,a)=>{let y=i(d,a);return j(y,a,this,d)}:this.validator=()=>[],o?this.refiner=(d,a)=>{let y=o(d,a);return j(y,a,this,d)}:this.refiner=()=>[]}assert(n,t){return A(n,this,t)}create(n,t){return T(n,this,t)}is(n){return L(n,this)}mask(n,t){return O(n,this,t)}validate(n,t={}){return E(n,this,t)}};function A(e,n,t){let r=E(e,n,{message:t});if(r[0])throw r[0]}function T(e,n,t){let r=E(e,n,{coerce:!0,message:t});if(r[0])throw r[0];return r[1]}function O(e,n,t){let r=E(e,n,{coerce:!0,mask:!0,message:t});if(r[0])throw r[0];return r[1]}function L(e,n){return!E(e,n)[0]}function E(e,n,t={}){let r=x(e,n,t),i=V(r);return i[0]?[new k(i[0],function*(){for(let c of r)c[0]&&(yield c[0])}),void 0]:[void 0,i[1]]}function U(...e){let n=e[0].type==="type",t=e.map(i=>i.schema),r=Object.assign({},...t);return n?S(r):g(r)}function p(e,n){return new f({type:e,schema:null,validator:n})}function B(e,n){return new f({...e,refiner:(t,r)=>t===void 0||e.refiner(t,r),validator(t,r){return t===void 0?!0:(n(t,r),e.validator(t,r))}})}function G(e){return new f({type:"dynamic",schema:null,*entries(n,t){yield*e(n,t).entries(n,t)},validator(n,t){return e(n,t).validator(n,t)},coercer(n,t){return e(n,t).coercer(n,t)},refiner(n,t){return e(n,t).refiner(n,t)}})}function K(e){let n;return new f({type:"lazy",schema:null,*entries(t,r){n??(n=e()),yield*n.entries(t,r)},validator(t,r){return n??(n=e()),n.validator(t,r)},coercer(t,r){return n??(n=e()),n.coercer(t,r)},refiner(t,r){return n??(n=e()),n.refiner(t,r)}})}function Q(e,n){let{schema:t}=e,r={...t};for(let i of n)delete r[i];switch(e.type){case"type":return S(r);default:return g(r)}}function X(e){let n=e instanceof f?{...e.schema}:{...e};for(let t in n)n[t]=C(n[t]);return g(n)}function Y(e,n){let{schema:t}=e,r={};for(let i of n)r[i]=t[i];return g(r)}function Z(e,n){return console.warn("superstruct@0.11 - The `struct` helper has been renamed to `define`."),p(e,n)}function ee(){return p("any",()=>!0)}function ne(e){return new f({type:"array",schema:e,*entries(n){if(e&&Array.isArray(n))for(let[t,r]of n.entries())yield[t,r,e]},coercer(n){return Array.isArray(n)?n.slice():n},validator(n){return Array.isArray(n)||`Expected an array value, but received: ${u(n)}`}})}function te(){return p("bigint",e=>typeof e=="bigint")}function re(){return p("boolean",e=>typeof e=="boolean")}function ie(){return p("date",e=>e instanceof Date&&!isNaN(e.getTime())||`Expected a valid \`Date\` object, but received: ${u(e)}`)}function oe(e){let n={},t=e.map(r=>u(r)).join();for(let r of e)n[r]=r;return new f({type:"enums",schema:n,validator(r){return e.includes(r)||`Expected one of \`${t}\`, but received: ${u(r)}`}})}function ce(){return p("func",e=>typeof e=="function"||`Expected a function, but received: ${u(e)}`)}function se(e){return p("instance",n=>n instanceof e||`Expected a \`${e.name}\` instance, but received: ${u(n)}`)}function fe(){return p("integer",e=>typeof e=="number"&&!isNaN(e)&&Number.isInteger(e)||`Expected an integer, but received: ${u(e)}`)}function ae(e){return new f({type:"intersection",schema:null,*entries(n,t){for(let r of e)yield*r.entries(n,t)},*validator(n,t){for(let r of e)yield*r.validator(n,t)},*refiner(n,t){for(let r of e)yield*r.refiner(n,t)}})}function de(e){let n=u(e),t=typeof e;return new f({type:"literal",schema:t==="string"||t==="number"||t==="boolean"?e:null,validator(r){return r===e||`Expected the literal \`${n}\`, but received: ${u(r)}`}})}function ue(e,n){return new f({type:"map",schema:null,*entries(t){if(e&&n&&t instanceof Map)for(let[r,i]of t.entries())yield[r,r,e],yield[r,i,n]},coercer(t){return t instanceof Map?new Map(t):t},validator(t){return t instanceof Map||`Expected a \`Map\` object, but received: ${u(t)}`}})}function M(){return p("never",()=>!1)}function le(e){return new f({...e,validator:(n,t)=>n===null||e.validator(n,t),refiner:(n,t)=>n===null||e.refiner(n,t)})}function pe(){return p("number",e=>typeof e=="number"&&!isNaN(e)||`Expected a number, but received: ${u(e)}`)}function g(e){let n=e?Object.keys(e):[],t=M();return new f({type:"object",schema:e||null,*entries(r){if(e&&m(r)){let i=new Set(Object.keys(r));for(let o of n)i.delete(o),yield[o,r[o],e[o]];for(let o of i)yield[o,r[o],t]}},validator(r){return m(r)||`Expected an object, but received: ${u(r)}`},coercer(r){return m(r)?{...r}:r}})}function C(e){return new f({...e,validator:(n,t)=>n===void 0||e.validator(n,t),refiner:(n,t)=>n===void 0||e.refiner(n,t)})}function ye(e,n){return new f({type:"record",schema:null,*entries(t){if(m(t))for(let r in t){let i=t[r];yield[r,r,e],yield[r,i,n]}},validator(t){return m(t)||`Expected an object, but received: ${u(t)}`}})}function me(){return p("regexp",e=>e instanceof RegExp)}function he(e){return new f({type:"set",schema:null,*entries(n){if(e&&n instanceof Set)for(let t of n)yield[t,t,e]},coercer(n){return n instanceof Set?new Set(n):n},validator(n){return n instanceof Set||`Expected a \`Set\` object, but received: ${u(n)}`}})}function v(){return p("string",e=>typeof e=="string"||`Expected a string, but received: ${u(e)}`)}function be(e){let n=M();return new f({type:"tuple",schema:null,*entries(t){if(Array.isArray(t)){let r=Math.max(e.length,t.length);for(let i=0;it.type).join(" | ");return new f({type:"union",schema:null,coercer(t){for(let r of e){let[i,o]=r.validate(t,{coerce:!0});if(!i)return o}return t},validator(t,r){let i=[];for(let o of e){let[...c]=x(t,o,r),[s]=c;if(s[0])for(let[d]of c)d&&i.push(d);else return[]}return[`Expected the value to satisfy a union of \`${n}\`, but received: ${u(t)}`,...i]}})}function z(){return p("unknown",()=>!0)}function N(e,n,t){return new f({...e,coercer:(r,i)=>L(r,n)?e.coercer(t(r,i),i):e.coercer(r,i)})}function we(e,n,t={}){return N(e,z(),r=>{let i=typeof n=="function"?n():n;if(r===void 0)return i;if(!t.strict&&H(r)&&H(i)){let o={...r},c=!1;for(let s in i)o[s]===void 0&&(o[s]=i[s],c=!0);if(c)return o}return r})}function ge(e){return N(e,v(),n=>n.trim())}function $e(e){return h(e,"empty",n=>{let t=P(n);return t===0||`Expected an empty ${e.type} but received one with a size of \`${t}\``})}function P(e){return e instanceof Map||e instanceof Set?e.size:e.length}function ke(e,n,t={}){let{exclusive:r}=t;return h(e,"max",i=>r?ir?i>n:i>=n||`Expected a ${e.type} greater than ${r?"":"or equal to "}${n} but received \`${i}\``)}function xe(e){return h(e,"nonempty",n=>P(n)>0||`Expected a nonempty ${e.type} but received an empty one`)}function Le(e,n){return h(e,"pattern",t=>n.test(t)||`Expected a ${e.type} matching \`/${n.source}/\` but received "${t}"`)}function Me(e,n,t=n){let r=`Expected a ${e.type}`,i=n===t?`of \`${n}\``:`between \`${n}\` and \`${t}\``;return h(e,"size",o=>{if(typeof o=="number"||o instanceof Date)return n<=o&&o<=t||`${r} ${i} but received \`${o}\``;if(o instanceof Map||o instanceof Set){let{size:c}=o;return n<=c&&c<=t||`${r} with a size ${i} but received one with a size of \`${c}\``}else{let{length:c}=o;return n<=c&&c<=t||`${r} with a length ${i} but received one with a length of \`${c}\``}})}function h(e,n,t){return new f({...e,*refiner(r,i){yield*e.refiner(r,i);let o=t(r,i),c=j(o,i,e,r);for(let s of c)yield{...s,refinement:n}}})}var l=typeof unsafeWindow<"u"?unsafeWindow:window,Se=new Event("namuwikinavigationwithadvert"),I=new Event("namuwikinavigation"),Ne=new Event("namuwikifristvisit"),He=e=>{if(Array.isArray(e)){if(e.toString().includes("//adcr.naver.com/adcr?"))return!0}else for(let n of Object.keys(e))try{if(typeof e[n]=="string"&&e[n].includes("//adcr.naver.com/adcr?"))return!0}catch{}return!1},Ae=e=>!Number.isNaN(Number(e)),Te=b.object({enable_ads:b.define("IsFakeNumber",Ae)}),Oe=e=>typeof e[0]<"u"&&typeof e[0]=="object"&&b.validate(e,Te)&&He(e[0]);l.Object.defineProperty=new Proxy(l.Object.defineProperty,{apply(e,n,t){Oe(t)?console.debug("[NamuLink:index]: Object.defineProperty:",[e,n,t]):Reflect.apply(e,n,t)}});l.TextDecoder.prototype.decode=new Proxy(l.TextDecoder.prototype.decode,{apply(e,n,t){let r=Reflect.apply(e,n,t);return r.includes("//adcr.naver.com/adcr?")?(console.debug("[NamuLink:index]: TextDecoder.prototype.decode:",[e,n,t]),l.dispatchEvent(I),l.dispatchEvent(Se),new Error):((r==="enable_ads"||decodeURIComponent(location.href).includes(r))&&l.dispatchEvent(I),r)}});l.Array.prototype.push=new Proxy(l.Array.prototype.push,{apply(e,n,t){t.toString().includes("//adcr.naver.com/adcr?")?(console.debug("[NamuLink:index]: Array.prototype.push:",[e,n,t]),l.dispatchEvent(Ne)):Reflect.apply(e,n,t)}});var w=[],Ce=e=>{w.push(...e),e.forEach(n=>{n.style.setProperty("display","none","important")})},ve=()=>{console.debug("[NamuLink:index]: ShowElements:",w),w=w.filter(e=>e.parentElement!==null),w.forEach(e=>{e.style.removeProperty("display")}),w=[]},q=()=>{let e=Array.from(l.document.querySelectorAll('article div:not([class*=" "]):has(h1)~ div * ~ div[class]'));e.push(...Array.from(l.document.querySelectorAll('article div:not([class*=" "]):has(h1) ~ *')));let n=e.filter(i=>i instanceof HTMLElement);var t=[];let r=[];t=n.filter(i=>i.innerText.length<25),t=t.filter(i=>Array.from(i.querySelectorAll("*")).filter(s=>s instanceof HTMLElement).some(s=>Number(getComputedStyle(s).getPropertyValue("margin-bottom").replace(/px$/,""))>=4)),t=t.filter(i=>Array.from(i.querySelectorAll("*")).filter(c=>c instanceof HTMLIFrameElement).length===0),r.push(...t.filter(i=>Array.from(i.querySelectorAll("*")).filter(s=>s instanceof HTMLElement).filter(s=>getComputedStyle(s).getPropertyValue("animation-iteration-count")==="infinite").length>=6)),r.push(...t.filter(i=>Array.from(i.querySelectorAll("*")).filter(s=>s instanceof HTMLElement).some(s=>Number(getComputedStyle(s).getPropertyValue("margin-bottom").replace(/px$/,""))>=10))),console.debug("[NamuLink:index]: HideLeftoverElement:",r),Ce(r)};l.addEventListener("namuwikinavigationwithadvert",q);l.addEventListener("namuwikifristvisit",q);l.addEventListener("namuwikinavigation",ve);})(); diff --git a/package.json b/package.json index 4cd2597..3ba1533 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "namulink", - "version": "3.1.0", + "version": "3.1.1", "description": "", "type": "module", "scripts": { diff --git a/sources/banner.txt b/sources/banner.txt index dec1cdf..3e50661 100644 --- a/sources/banner.txt +++ b/sources/banner.txt @@ -8,7 +8,7 @@ // @downloadURL https://cdn.jsdelivr.net/gh/List-KR/NamuLink@latest/NamuLink.user.js // @license MIT // -// @version 3.1.0 +// @version 3.1.1 // @author PiQuark6046 and contributors // // @match https://namu.wiki/* diff --git a/sources/src/index.ts b/sources/src/index.ts index 1ec95d3..bbd930d 100644 --- a/sources/src/index.ts +++ b/sources/src/index.ts @@ -57,7 +57,7 @@ Win.TextDecoder.prototype.decode = new Proxy(Win.TextDecoder.prototype.decode, { return new Error() } - if (Decoded === 'enable_ads') { + if (Decoded === 'enable_ads' || decodeURIComponent(location.href).includes(Decoded)) { Win.dispatchEvent(NagivationEvent) }