trackkun-dom 2.0.0 → 2.0.1

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.
Files changed (3) hide show
  1. package/index.js +1 -1
  2. package/package.json +1 -1
  3. package/stripper.js +1 -1
package/index.js CHANGED
@@ -1 +1 @@
1
- (function(P,B){typeof exports=="object"&&typeof module<"u"?B(exports):typeof define=="function"&&define.amd?define(["exports"],B):(P=typeof globalThis<"u"?globalThis:P||self,B(P._trackkun_={}))})(this,function(P){"use strict";function B(a){let e=!1;return new Promise((t,r)=>{Promise.all(a.map(async s=>{const n=await s;!e&&n&&(e=!0,t(n))})).then(()=>{e||t(void 0)})})}function W(a,{removeTrailingSlash:e=!0}={}){if(!a)return;const t=e&&a.endsWith("/")?a.slice(0,-1):a;try{return new URL(t)}catch{return}}function x(a){if(!(!a||typeof a!="string"))return a.startsWith("http://")||a.startsWith("https://")?W(a)?.pathname:a.startsWith("//")?W(`https:${a}`)?.pathname:a}async function N(a,e,t){const r=await t(()=>{a=0});if(r!==void 0)return r;if(!(a<=0))return await new Promise(s=>{setTimeout(async()=>{const n=await N(a-1,e,t);s(n)},e)})}async function I(a,e,t=0){const r=e.root??document.documentElement,s=e.timeoutMs??1e4;return N(e.lazy===!0?s/50:0,50,()=>{const n=e.all===!0?Array.from(r.querySelectorAll(a)):r.querySelector(a)??void 0;return(e.all?!n?.length:!n)?void 0:n})}const Q={text:je,attr:Le,"attr-contain":Oe,value:Ne,row:_e,"bg-image":ze};function g(a,e){if(a)return J(a,e,Pe)}function _(a,e){if(a)return J(a,e,Be)}function J(a,e,t){if(!a)return;const r=a.split("||").map(s=>s.trim()).filter(s=>!!s&&s.includes("|"));for(const s of r){const n=Ce(s);if(!n)continue;const i=t(e??document.documentElement,n.selector,n.instructions);if(i)return i}}function Ce(a){const[e,t]=a.split("|");if(!t)return;const r=(t?.startsWith("[")&&t.endsWith("]")?t.substring(1,t.length-1).split(","):[t]).map(s=>{const n=s.indexOf(":"),i=n!==-1;return{extractor:i?s.substring(0,n):s,param:i?s.substring(n+1):""}});return{selector:e||void 0,instructions:r}}function Pe(a,e,t){if(!e)return Y(a,t);const r=e.split(",");for(const s of r){const n=Array.from(a.querySelectorAll(s));for(const i of n){const o=Y(i,t);if(o)return o}}}function Be(a,e,t){const r=e?Array.from(a.querySelectorAll(e)):[a],s=[];for(const n of r)for(const i of t){const o=Q[i.extractor],l=o(n,i.param);if(l){s.push(l);break}}if(s.length)return s}function Y(a,e){for(const t of e){const r=Q[t.extractor],s=r(a,t.param);if(s)return s}}function je(a){return Array.from(a.childNodes).filter(e=>e.nodeType===3).map(e=>j(e.textContent)).filter(Boolean).join(" ").trim()||j(a.textContent)}function Le(a,e){return j(a.getAttribute(e))}function Oe(a,e){let t=a.getAttribute(e);if(!t){const r=a.getAttributeNames().find(s=>s.includes(e));r&&(t=a.getAttribute(r))}return j(t)}function Ne(a){return a.value}function _e(a,e){if(!e)return;const t=j(a.textContent)?.toLowerCase(),r=e.toLowerCase();if(!(t!==r&&t!==`${r}:`))return j(a.nextElementSibling?.textContent??a.nextSibling?.textContent)}function ze(a){const e=getComputedStyle(a).backgroundImage;if(!(!e||!e.startsWith("url(")))return e.slice(5,-2)||void 0}function j(a){if(a)return a?.replace(/(\n|\t)/g," ").trim()||void 0}var Ae=(a=>(a[a.reading=1]="reading",a[a.paused=2]="paused",a[a.plan=3]="plan",a[a.completed=4]="completed",a[a.dropped=5]="dropped",a[a.deleted=6]="deleted",a))(Ae||{}),ke=(a=>(a[a.ok=1]="ok",a[a.hidden=2]="hidden",a[a.deleted=3]="deleted",a))(ke||{}),We=(a=>(a[a.aggregator=0]="aggregator",a[a.scanlator=1]="scanlator",a))(We||{}),Ee=(a=>(a[a.pending=0]="pending",a[a.completed=1]="completed",a[a.offline=2]="offline",a[a.incompat=3]="incompat",a))(Ee||{}),E=(a=>(a.id="id",a.name="name",a.slug="slug",a))(E||{}),A=(a=>(a.blank="about:blank",a.title="meta.title",a.reader="meta.reader",a))(A||{});const Ue=/(vol(ume)?|season)(\s*|-|\.)(\d+)/i,qe=/^S([1-9])\s/i,Fe=/(ch(ap(t(er)?|\.)?|\.)?|^#|episode\.?|capitolo\.?|capitulo\.?|bölüm\.?)(\s*|-)(\d+([_-~,.]\d+)?)/i,Ve=/\d+([_-~,.]\d+)?/,He=/[_-~,]/;function Qe(a){const e=a.match(Ue);if(e)return{volStr:e[0],volValueStr:e[4]};const t=a.match(qe);return t?{volStr:t[0],volValueStr:t[1]}:{}}function L(a){if(!a)return;if(!isNaN(+a))return{chap:+a};const{volStr:e,volValueStr:t}=Qe(a),r=e?a.replace(e,"").trim():a,s=r.match(Fe),n=r.match(Ve),i=s?.[6],o=i??n?.[0];if(!o)return;const l=+o.replace(He,".");return isNaN(l)?void 0:{vol:e&&t&&!isNaN(+t)&&a.indexOf(e)<a.indexOf(i?s[0]:n[0])?+t:void 0,chap:l}}async function Z(a,e=240){return new Promise(t=>{const r=new Image;r.crossOrigin="anonymous",r.onerror=()=>t(void 0),r.onload=()=>{const s=document.createElement("canvas"),n=s.getContext("2d"),i=Math.max(1,r.naturalWidth/e),o=r.naturalWidth/i,l=r.naturalHeight/i;s.width=o,s.height=l;const c=/iPad|iPhone|iPod/.test(navigator.userAgent);try{n.drawImage(r,0,0,o,l);const u=s.toDataURL(c?"image/jpg":"image/webp",c?.99:.8).split(",").slice(-1)[0];t(u)}catch{t(void 0)}},r.src=a})}async function Je(a,e=240){const t=await Ye(a);if(t)return await new Promise(async r=>{const s=Z(t,e),n=setTimeout(()=>r(void 0),100),i=await s;clearTimeout(n),r(i)})}async function Ye(a){try{const e=await fetch(a);if(e.status>=400)return;const t=await e.blob();return URL.createObjectURL(t)}catch{return}}function z(a){return a.sort((e,t)=>e.vol===void 0||t.vol===void 0?t.chap-e.chap:t.vol-e.vol||t.chap-e.chap),Ze(a)}function Ze(a){const e={};for(let t=a.length-1;t>=0;t--){const r=a[t],s=r.lang??"";r.vol!==void 0?e[s]=r.vol:e[s]!==void 0&&(r.inferVol=e[s])}return a}const Ge=[{seconds:1,locales:{en:"sec",vi:"gi\xE2y",tr:"ikinci",es:"segunda"}},{seconds:60,locales:{en:"min",vi:"ph\xFAt",tr:"dakika"}},{seconds:3600,locales:{en:"hour",vi:"gi\u1EDD",tr:"saat",fr:"heure",it:"ora",es:"hora"}},{seconds:86400,locales:{en:"day",vi:"ng\xE0y",tr:"g\xFCn",fr:"jour",it:"giorno",es:"d\xEDa"}},{seconds:604800,locales:{en:"week",vi:"tu\u1EA7n",tr:"hafta",fr:"semaine",it:"settimana",es:"semana"}},{seconds:2592e3,locales:{en:"month",vi:"th\xE1ng",tr:"ay",fr:"mois",it:"mese",es:"mes"}},{seconds:31536e3,locales:{en:"year",vi:"n\u0103m",tr:"yil",fr:"an",it:"anno",es:"a\xF1o"}}];function G(a,e){const t=a?.toLowerCase();if(!t)return;const r=Date.now();if(t.includes("now"))return r;if(t.includes("yesterday"))return r-864e5;const s=new Date(t);if(s instanceof Date){const c=s.valueOf();if(!isNaN(c))return s.getHours()===0&&s.getMinutes()===0?Math.min(r,c+432e5):c}const n=Ge.find(c=>e&&c.locales[e]&&t.indexOf(c.locales[e])!==-1?!0:t.indexOf(c.locales.en)!==-1);if(!n)return;const i=t.split(" ").filter(Boolean),o=K(i)??(e==="en"?K(i,["a","an"]):void 0);if(!o)return;const l=r-o*n.seconds*1e3;return l>0?l:void 0}function K(a,e){for(let t=0;t<a.length;t++){const r=a[t];if(e?.includes(r))return 1;const s=+r;if(s)return s<0?void 0:s}}function X(a,e=location.origin){if(!a)return;const t=new URL(a.startsWith("//")?`${location.protocol}${a}`:a,location.origin+location.pathname).toString();return t.startsWith(e)?t.replace(e,""):t}function ee(a,{titleSlug:e,titleId:t}){if(!a)return"/";let r=a.replace("{titleSlug}",e);t&&(r=r.replace("{titleId}",t));const s=r.endsWith("/")?r:r+"/";return s.startsWith("/")?s:"/"+s}function Ke(a,e){const t=[...e],r=[];let s=!1,n=0;const i=Math.min(a.length,100);for(let l=0;l<i;l++){if(n>=10/2){const p=10-r.length;if(p>0){const v=l+p<=a.length?a.slice(l,l+p):t.slice(0,p);r.push(...v)}break}const c=a[l],u=c.id!==void 0,d=t.findIndex(p=>u&&p.id===c.id||p.slug===c.slug||p.name==c.name),h=d===-1?void 0:t.splice(d,1)[0];!h||h.chapters[0]?.chap!==c.chapters[0]?.chap?(s=!0,r.push({...c,changed:!0})):(n++,r.push(c))}if(!s)return{hasMore:!1,rawReleases:[]};if(r.length<=10)return{hasMore:!!a[a.length-1]?.changed,rawReleases:r};const o=[];for(let l=0;l<r.length;l++){const c=r[l];(c.changed||l<10)&&o.push(c)}return{hasMore:e.length<2||e.length-t.length<2,rawReleases:o}}function Xe(a,e){const t={};return a.forEach(r=>{const s=r.chapters.reduce((n,i)=>{const o=i.lang||e||"";return n[o]||(n[o]=[]),n[o].push(i),n},{});Object.entries(s).forEach(([n,i])=>{const o=`${r.slug}:${n}`;t[o]?(t[o].chapters.push(...i),z(t[o].chapters)):t[o]={...r,lang:n===""?void 0:n,chapters:i}})}),Object.values(t)}var S=(a=>(a.title="title",a.reader="reader",a.releases="releases",a.chapters="chapters",a.search="search",a))(S||{}),et=Object.defineProperty,tt=(a,e,t)=>e in a?et(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,$=(a,e,t)=>(tt(a,typeof e!="symbol"?e+"":e,t),t);class k{constructor(e){$(this,"headless"),$(this,"siteId"),$(this,"spec"),$(this,"siteMeta"),$(this,"tags"),$(this,"context"),$(this,"methodsMap",{[S.title]:()=>this.getRawTitleData(),[S.reader]:()=>this.getRawReaderData(),[S.releases]:()=>this.getRawReleasesData(),[S.search]:()=>this.getRawSearchData(),[S.chapters]:()=>this.getRawChaptersData()}),$(this,"normalizedTagsMap"),this.siteId=e.siteId,this.spec=e.spec,this.siteMeta=e.siteMeta,this.tags=e.tags,this.context=e.context??{},this.headless=e.headless===!0}async getRawSearchData(){throw new Error("Unimplemented")}async getRawPageByType(e,t=!1){const r=await this.methodsMap[e](),s=!r&&(e===S.title||e===S.reader)&&await rt(this.spec);if(t&&!r&&!s)return;const n=location.origin+location.pathname;return{type:e,is404:s,specId:this.spec.id,siteName:g(this.spec.name),url:n,data:r,spec:this.spec,context:this.context}}parseReaderSlug(e,t,r){let s=t;if(s[0]!=="/"&&s.includes("/"))try{s=new URL(t,location.href).pathname}catch{}const n=s.endsWith("/")?s.slice(0,-1):s;if(e.includes("{")){const i=e.split("/").filter(Boolean),o=n.split("/").filter(Boolean);if(i.length<o.length){const l=o[i.indexOf("{lang}")],c=o[i.indexOf("{titleId}")],u=o[i.indexOf("{titleSlug}")],d=e.replace("{lang}",l).replace("{titleId}",c).replace("{titleSlug}",u);if(n.startsWith(d))return{basePath:d,lang:l.toLowerCase(),titleId:c,titleSlug:u,slug:n.replace(d,"")}}}else if(n.startsWith(e))return{basePath:e,slug:n.replace(e,"")};return{basePath:"",slug:n[0]==="/"?n.substring(1):n}}parseTitleSlug(e){if(typeof e!="string")return{};const t=x(e),r=t?.split("/").filter(Boolean);if(!r?.length)return{};const s=this.siteMeta.titleBase.split("/").filter(Boolean),n=s.indexOf("{slug}");return(n===-1?r.length-s.length>=1:r.length===s.length)?{id:r[s.indexOf("{id}")],slug:n===-1?r.slice(s.length).join("/"):r[n]}:{slug:t}}finalizeRawReleasesData(e){const t=this.spec.releases?.title?.lang?this.siteMeta.defaultLang:void 0,r=Xe(e.rawReleases,t);if(r.length)return this.context.oldRawReleases?Ke(r,this.context.oldRawReleases):{rawReleases:r,hasMore:!0}}getTagIdsFromNames(e){if(!e?.length)return;const t=this.normalizedTagsMap??(this.normalizedTagsMap=at(this.tags)),r=e.map(s=>t[U(s)]).filter(Boolean);return r.length===0?void 0:Array.from(new Set(r)).sort((s,n)=>s-n)}}$(k,"specId"),$(k,"siteId");function at(a){const e={};return a.forEach(({id:t,name:r,altNames:s})=>{e[U(r)]=t,s&&s.forEach(n=>{e[U(n)]=t})}),e}function U(a){const e=a.toLowerCase().replaceAll(" ","").replaceAll("-","");return e[e.length-1]==="s"?e.substring(0,e.length-1):e}async function rt(a){return st()===404||a[404]&&await I(a[404],{lazy:!0,timeoutMs:5e3})?!0:document.title.toLowerCase().includes("not found")}function st(){try{return window.performance.getEntries().find(a=>a.entryType==="navigation")?.responseStatus}catch{return}}class m extends k{async getRawReleasesData(){if(!this.spec?.releases?.title)return;const{chapter:e,...t}=this.spec.releases.title,r=await I(t.sel,{lazy:!0,all:!0});if(!r?.length)return;const s=r.slice(0,100).map(i=>{const o=g(t.url,i),l=x(o),c=g(t.name,i),u=g(t.at,i);if(!(!l||!c))return{titleEl:i,id:g(t.id,i),path:l,name:c,lang:g(t.lang,i)?.toLowerCase(),at:G(u,this.siteMeta.defaultLang)}}).filter(Boolean);if(!s.length)return;const n=[];return await Promise.all(s.map(async i=>{const{path:o,titleEl:l,lang:c,at:u,...d}=i,{id:h,slug:p}=this.parseTitleSlug(o);if(!p)return;const v=d.id||h,y=await this.getChapters(e,{root:l,titleId:v,titleSlug:p})??[];y.length&&n.push({slug:p,chapters:c||u?y.map(w=>({...w,elIndex:void 0,lang:w.lang??c,ts:w.ts??u})):y,...d,id:v})})),this.finalizeRawReleasesData({rawReleases:n})}getRawTitleData(){return this.getTitleData(this.spec.title)}async getTitleData(e){if(!e||(e.sel||e.lazy)&&!await I(e.sel??e.name,{lazy:!!e.lazy}))return;const t=g(e.name);if(!t)return;const{id:r,slug:s}=this.parseTitleSlug(location.pathname);if(!s)return;const n=_(e.tags)?.map(h=>h.split(",")).flat().map(h=>h.trim()).filter(Boolean),i=g(e.type),o=_(e.langs)?.map(h=>h.toLowerCase()),l=r||g(e.id),c=await this.getChapters(e.chapter,{lazy:!0,titleId:l,titleSlug:s})??[],u=e.img?await this.getValidImgSrc(e.img):void 0,d=u&&this.context.includeImgBytes?await Je(u):void 0;return{id:l||g(e.id),url:location.origin+location.pathname,slug:s,name:t,langs:o?.length?o:e.langs&&this.siteMeta.defaultLang?[this.siteMeta.defaultLang]:void 0,tags:this.getTagIdsFromNames([...n??[],...i?[i]:[]]),chapters:c,hasMoreChapters:e.hasMore?!!document.querySelector(e.hasMore):void 0,img:u,imgBytes:d,firstUrl:this.getFirstChapterUrl()}}getFirstChapterUrl(){const e=g(this.spec.title?.first);if(e){if(e.startsWith("http"))return e;try{return new URL(e,location.href).href}catch{return}}}getValidImgSrc(e){return N(33,30,()=>{const t=g(e);return t&&!t.startsWith("data:")?t.split(" ")[0]:void 0})}getRawReaderTitleData(){const e=this.spec.reader?.title;if(!e)return;const t=e.sel?document.querySelector(e.sel)??void 0:void 0,r=g(e.name,t),s=g(e.url,t),{slug:n,id:i}=this.parseTitleSlug(s),o=X(g(e.img,t));if(!(!r||!s||!n))return{name:r,img:o,url:s,slug:n,id:i||g(e.id)}}async getRawReaderData(){const{spec:e,siteMeta:t}=this;if(!e?.reader||e.generic&&!await m.isReaderPage(e.reader))return;const r=e.reader.content;if(!(!r||await m.verifyImgsCotainer(r)))return;const s=this.getRawReaderTitleData();if(!s)return;const{id:n,slug:i}=s,o=e.reader?.chapter,l=!!this.context.disableLazyChapters,c=!!this.context.includeHiddenChapters,u=await this.getChapters(o,{titleId:n,titleSlug:i,lazy:c||!l,includeHiddenChapters:c,timeoutMs:c?3e3:12e4,includeIndex:!0})??[],d=g(e.reader.label)?.toLowerCase().replace(s.name.toLowerCase(),"");if(!d)return;const{vol:h,chap:p=0}=L(d)||{},{slug:v,basePath:y,lang:w,titleId:b}=this.parseReaderSlug(ee(t.readerBase,{titleId:n,titleSlug:i}),location.pathname,location.href),f=this.findNeighborChapter({sel:e.reader.prev,basePath:y}),C=this.findNeighborChapter({sel:e.reader.next,basePath:y});return this.finalizeRawReaderData({vol:h,chap:p,lang:w??g(e.reader.lang)?.toLowerCase()??(e.reader.lang?this.siteMeta.defaultLang:void 0),slug:v,basePath:y,imgs:_(e.reader.imgs),title:{id:n||b||g(this.spec.reader?.title.id),url:s.url,slug:i,name:s.name,langs:w?[w]:void 0,img:s.img,chapters:u,hasMoreChapters:!u.length&&!c&&!!this.context.disableLazyChapters&&!!o?.label}},{prevSlug:f,nextSlug:C})}async getRawChaptersData(){const e=this.siteMeta.chapters;if(e===A.blank)return;const t=e===A.reader,r=!e||e===A.title,s=t?(await this.getRawReaderData())?.title:r?await this.getRawTitleData():void 0;let n=s?.chapters;if(!t&&!r&&(n=await this.getChapters(this.spec.chapters?.chapter,{lazy:this.spec.chapters?.lazy})),!n)return;const{lang:i}=this.context,o=i?n.filter(l=>!l.lang||l.lang===i):n;return{chapters:o,title:s?{...s,chapters:[]}:await this.getTitleData(this.spec.chapters?.title),hasMore:!1,asc:!1,total:o.length}}async getRawSearchData(){const e=this.spec.search?.title;if(!e)return;const{chapter:t}=e,r=[];return await Promise.all(Array.from(document.querySelectorAll(e.sel)).map(async s=>{const n=g(e.url,s),i=x(n),o=g(e.name,s),{slug:l,id:c}=this.parseTitleSlug(i);!i||!o||!l||r.push({id:c,slug:l,name:o,chapters:await this.getChapters(t,{root:s,titleId:c,titleSlug:l})??[]})})),r.length?{rawReleases:r}:void 0}async getChapters(e,{root:t,titleId:r="",titleSlug:s="",includeHiddenChapters:n=!1,lazy:i=!0,timeoutMs:o,includeIndex:l}={}){if(!e||!e.sel||!e.label)return;let c=null;if(e.trigger){if(!n||(c=document.querySelector(e.trigger),!c))return;c.click()}const u=[],d=await I(e.sel,{root:t,all:!0,lazy:i,timeoutMs:o});if(!d?.length)return c?.click(),[];const h=(d??[]).map((b,f)=>({id:g(e.id,b),label:g(e.label,b),url:g(e.url,b),at:g(e.at,b),elIndex:f}));c?.click();const p=h.map(({label:b})=>L(b)),v=p[1]?.chap;!p[0]&&(v===void 0||v<=1)&&(p[0]={chap:0});const{readerBase:y}=this.siteMeta,w=ee(y,{titleId:r,titleSlug:s});return p.forEach((b,f)=>{if(!b)return;const{id:C,url:D,at:F,elIndex:V}=h[f],R={...b,id:C,ts:G(F,this.siteMeta.defaultLang)};l&&(R.elIndex=V);const De=D?.startsWith("http")&&!D.includes(`//${location.hostname}/`),H=De?D:x(D);if(!H){u.push(R);return}if(De){u.push({...R,slug:H});return}const{slug:wa,lang:va}=this.parseReaderSlug(w,H,D);u.push({...R,slug:wa,lang:va})}),z(u)}static async isReaderPage(e){return!!e.sel&&!!await I(e.sel,{lazy:!!e.lazy})}static async verifyImgsCotainer(e){const t=e.split(",").map(r=>r.trim()).filter(Boolean).map(r=>`${r} img, ${r} canvas`).join(",");return!!await I(t,{lazy:!0,all:!1})}findNeighborChapter({sel:e,basePath:t}){const r=g(e);if(!r||r.startsWith("#")||r.startsWith("/#"))return;const s=x(r);if(s)return this.parseReaderSlug(t,s,r).slug||void 0}finalizeRawReaderData(e,{prevSlug:t,nextSlug:r}={}){const s=e.title.chapters;if(!s.length){const c=L(t),u=L(r);return!c&&!u?e:{...e,prev:c?{...c,slug:t}:void 0,next:u?{...u,slug:r}:void 0}}let n,i,o,l;for(let c=0;c<s.length&&!(n&&(!t||o)&&!r&&l);c++){const u=s[c];!n&&(e.slug==u.slug||e.chap===u.chap&&(e.vol===u.vol||e.vol===void 0))?(n=u,i=c):!o&&t===u.slug?o=u:!l&&r===u.slug&&(l=u)}return i!==void 0&&(o??(o=s[i+1]),l??(l=s[i-1])),{...e,inferVol:n?.inferVol,prev:o,next:l}}}var nt=Object.defineProperty,it=(a,e,t)=>e in a?nt(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,ot=(a,e,t)=>(it(a,typeof e!="symbol"?e+"":e,t),t);class te extends m{parseTitleSlug(e){return{slug:x(e)?.split("/").filter(Boolean)[1]}}async getRawTitleData(){if(!(!this.headless&&navigator.userAgent.toLowerCase().includes("android")))return await super.getRawTitleData()}}ot(te,"specId","bato");function lt(){return Math.random().toString(16).slice(2)}async function ct({addListener:a,removeListener:e,transform:t,filter:r,handler:s,onTimeout:n,timeout:i,once:o}){return new Promise(l=>{a(d);const c=()=>o===!0&&e(d),u=i?setTimeout(()=>{c(),l(void 0),n?.()},i):void 0;async function d(h,...p){h=t?t(h):h,h!==void 0&&(!r||r(h,...p))&&(c(),l(h),s?.(h,...p),u&&clearTimeout(u))}})}async function ut(a){return(await ct({addListener:e=>window.addEventListener("message",e),removeListener:e=>window.removeEventListener("message",e),...a}))?.data}async function gt(a){const{receiverWindow:e,timeout:t,targetOrigin:r,event:s,args:n}=a,i={reqId:lt(),event:s,args:n};return(e||window)?.postMessage(i,r??"*"),(await ut({filter:o=>o?.data?.resId===i.reqId,timeout:t??3e4,once:!0}))?.result}const O={isAny:!0};function T(a,...e){return gt({event:"tk:fetchResult",args:{baseUrl:a,segments:e}})}var dt=Object.defineProperty,ht=(a,e,t)=>e in a?dt(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,pt=(a,e,t)=>(ht(a,typeof e!="symbol"?e+"":e,t),t);const ae=class Te extends m{async getRawReleasesData(){let e;try{const r=Array.from({length:2},async(s,n)=>{const i=`https://api.${location.host}/chapter?accept_erotic_content=true&page=${n+1}&order=new`;return(await fetch(i)).json()});e=(await Promise.all(r)).flat()}catch{return}const t=[];return e.forEach(r=>{const{vol:s,chap:n,hid:i,lang:o,updated_at:l,md_comics:c}=r,u=typeof n=="string"&&!isNaN(+n)?+n:void 0;typeof u=="number"&&t.push({id:c.hid,slug:c.slug,name:c.title,chapters:[{slug:i,vol:typeof s=="string"&&!isNaN(+s)?+s:void 0,chap:u,lang:o,ts:new Date(l).valueOf()}]})}),super.finalizeRawReleasesData({rawReleases:t})}async getRawTitleData(){const e=await super.getRawTitleData();if(!e)return e;const t=await T(`https://api.${location.host}`,"comic",O,"chapters");if(!t)return e;const r=t.url.split("/").filter(Boolean).slice(-2)[0],s=re(t.value),n=g("h1 ~ div.text-sm span:first-child|row:demographic"),i=n?this.getTagIdsFromNames([n])?.[0]:void 0;return i&&!e.tags?.includes(i)&&(e.tags?.push(i),e.tags?.sort((o,l)=>o-l)),{...e,img:e.img??X(g(this.spec.title?.img)),id:r,hasMoreChapters:s?.hasMore??!1,chapters:s?.chapters??[]}}async getRawReaderData(){const e=await super.getRawReaderData();return e&&{...e,lang:e.lang&&e.lang?.length<=6?e.lang:Te.getLangFromReaderSlug(e.slug)||e.lang}}static getLangFromReaderSlug(e){const t=e.split("-");let r;for(let s=t.length-1;s>0;s--){const n=t[s];if(!isNaN(+n))break;r=r?`${n}-${r}`:n}return r&&r.length<=6?r:void 0}async getRawChaptersData(){if(!this.context.rawId)return;const{rawId:e,lang:t="en",skip:r}=this.context,s=r?Math.floor(r/1e3)+1:void 0;try{const n=await fetch(`https://api.${location.host}/comic/${e}/chapters?lang=${t}&limit=1000${s&&s>1?`&page=${s}`:""}`),i=re(await n.json());return i?{...i,lang:t,asc:!1}:void 0}catch{return}}};pt(ae,"specId","comick");let ft=ae;function re(a){if(!Array.isArray(a?.chapters))return;const e=[];return a.chapters.forEach(t=>{const{vol:r,chap:s,hid:n,lang:i,updated_at:o}=t,l=typeof s=="string"&&!isNaN(+s)?+s:void 0;typeof l!="number"||e.some(c=>c.vol==r&&c.chap===l&&c.lang===i)||e.push({slug:n,vol:typeof r=="string"&&!isNaN(+r)?+r:void 0,chap:l,lang:i,ts:new Date(o).valueOf()})}),{chapters:z(e),total:a.total??e.length,hasMore:a.total>a.limit}}var mt=Object.defineProperty,wt=(a,e,t)=>e in a?mt(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,vt=(a,e,t)=>(wt(a,typeof e!="symbol"?e+"":e,t),t);class se extends m{async getRawChaptersData(){const e=this.context.titleSlug;if(!e)return;const t=`https://api.${location.host}/chapter/all/${e}`;return{chapters:(await(await fetch(t)).json()).map(yt).filter(Boolean)}}}vt(se,"specId","lua");function yt(a){if(!a||typeof a.chapter_name!="string")return;const e=L(a.chapter_name);if(e)return{...e,slug:typeof a.chapter_slug=="string"?a.chapter_slug:void 0,ts:typeof a.created_at=="string"?new Date(a.created_at).valueOf():void 0}}function ne(a,e){const t=a[0]===e?a.substring(1):a;return t[t.length-1]===e?t.substring(0,t.length-1):t}var bt=Object.defineProperty,Rt=(a,e,t)=>e in a?bt(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,St=(a,e,t)=>(Rt(a,typeof e!="symbol"?e+"":e,t),t);class q extends m{async getRawReleasesData(){const e=this.detectNewSiteMeta(this.spec.releases,this.siteMeta);this.siteMeta=e??this.siteMeta;const t=await super.getRawReleasesData();if(t)return{...t,siteMeta:e}}async getRawTitleData(){const e=this.finalizeNewSiteMeta(this.siteMeta,{titleBase:this.extractBasePath(location.pathname)});this.siteMeta=e??this.siteMeta;const t=await super.getRawTitleData();if(t)return{...t,siteMeta:e}}async getRawReaderData(){const e=ie(this.spec.reader?.title);if(!e)return;const t=this.finalizeNewSiteMeta(this.siteMeta,{titleBase:this.extractBasePath(x(e))});this.siteMeta=t??this.siteMeta;const r=await super.getRawReaderData();if(r)return{...r,siteMeta:t}}async getRawSearchData(){const e=ie(this.spec.search?.title);if(!e)return;const t=this.finalizeNewSiteMeta(this.siteMeta,{titleBase:this.extractBasePath(x(e))});this.siteMeta=t??this.siteMeta;const r=await super.getRawSearchData();if(r)return{...r,siteMeta:t}}detectNewSiteMeta(e,t){if(!e)return;const r=e.title,s=document.querySelector(r.sel)??void 0;if(!s)return;const n=x(g(r.url,s));if(n!==void 0)return this.finalizeNewSiteMeta(t,{titleBase:this.extractBasePath(n)})}finalizeNewSiteMeta(e,{titleBase:t}){if(e.titleBase!==t)return{...e,titleBase:t,readerBase:e.readerBase.replace(e.titleBase,t)}}extractBasePath(e){return ne(e,"/").split("/").slice(0,-1).join("/")}}St(q,"specId","madara");function ie(a){if(!a)return;const e=a.sel?document.querySelector(a.sel)??void 0:void 0;return g(a.url,e)}var xt=Object.defineProperty,$t=(a,e,t)=>e in a?xt(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,It=(a,e,t)=>($t(a,typeof e!="symbol"?e+"":e,t),t);const Mt={a:.1,b:.2,c:.3,d:.4};class oe extends k{parseTitleSlug(e){return{slug:x(e)?.split("/").filter(Boolean)[1]}}async getRawReleasesData(){let e=[];try{e=(await(await fetch("https://api.mangadex.org/chapter?limit=96&offset=0&includes[]=manga&contentRating[]=safe&contentRating[]=suggestive&contentRating[]=erotica&contentRating[]=pornographic&order[readableAt]=desc")).json()).data}catch{return}const t=[];return e.forEach(({relationships:r,attributes:s,id:n})=>{const i=r.find(({type:d})=>d==="manga"),o=M(s.volume),l=M(s.chapter);if(l===void 0)return;const{title:c}=i.attributes,u=c.en??Object.values(c)[0];t.push({slug:i.id,name:u,chapters:[{slug:s.externalUrl||n,vol:o,chap:l,lang:s.translatedLanguage,ts:new Date(s.readableAt).valueOf()}]})}),super.finalizeRawReleasesData({rawReleases:t})}async getRawTitleData(){const e="https://api.mangadex.org/manga/",[t,r]=await Promise.all([T(e,O),T(e,O,"feed")]);if(!t||!r)return;const s=r.value.data?.map?.(l=>{const{attributes:c,id:u}=l;if(typeof c!="object"||typeof u!="string"||!u)return;const{externalUrl:d,title:h,volume:p,chapter:v,translatedLanguage:y}=c;return{slug:d||u,label:h||void 0,vol:M(p),chap:M(v),lang:y||"en",ts:new Date(c.readableAt).valueOf()}}).filter(l=>l?.chap!=null)??[],{data:n}=t.value;if(!n)return;const i=ce({data:n,getTagIdsFromNames:l=>this.getTagIdsFromNames(l)});if(!i)return;const o=this.context.includeImgBytes&&i.img?await Z(i.img):void 0;return{...i,imgBytes:o,chapters:z(s),hasMoreChapters:(r.value.total||0)>(r.value.limit||0)}}async getRawReaderData(){const e="https://api.mangadex.org/",[t,r,s]=await Promise.all([T(e,"chapter",O),T(e,"at-home","server",O),T(e,"manga",O,"aggregate")]);if(!t||!r||!s)return;const n=t.value.data,{volume:i,chapter:o,externalUrl:l,translatedLanguage:c}=n.attributes||{},{baseUrl:u,chapter:{data:d,dataSaver:h,hash:p}}=r.value,v=n.relationships?.find?.(R=>R.type==="manga");if(!v)return;const y=ce({data:v,getTagIdsFromNames:R=>this.getTagIdsFromNames(R)});if(!y||typeof s.value.volumes!="object")return;const w=le(s.value)??[];(typeof o!="string"||o==="none")&&!w.length&&w.push({chap:0,slug:n.id});const b=w.findIndex(R=>R.slug===n.id),f=n.relationships?.find?.(R=>R.type==="scanlation_group"),C=u.endsWith("/")?u:u+"/",D=!!localStorage.getItem("md")?.includes?.('"dataSaver":true'),F=`${C}${D?"data-saver":"data"}/`,V=((D?h:d)??[]).map?.(R=>`${F}${p}/${R}`)??[];return{externalUrl:l,vol:M(i),inferVol:w[b]?.inferVol,chap:M(o)||0,imgs:V,lang:c,slug:n.id,prev:w[b+1],next:w[b-1],basePath:"/chapter/",groupName:f?.attributes?.name,groupUrl:f?.attributes?.website,isWebtoon:v?.attributes?.tags?.some(R=>R.attributes.name.en==="Long Strip"),title:{...y,chapters:w}}}async getRawChaptersData(){const{titleSlug:e,lang:t="en"}=this.context;let r;try{const s=await fetch(`https://api.mangadex.org/manga/${e}/aggregate?translatedLanguage[]=${t}`);r=le(await s.json())}catch{return}if(r)return{chapters:r,lang:t,asc:!1,hasMore:!1,total:r.length}}}It(oe,"specId","mangadex");function M(a){if(typeof a!="string"||a==="none")return;const e=parseFloat(a);if(e!==e)return;const t=a[a.length-1];return e+(Mt[t]??0)}function le(a){if(typeof a.volumes!="object")return;const e=Object.values(a.volumes).map(({volume:t,chapters:r})=>{const s=M(t);return Object.values(r).map(({id:n,chapter:i})=>{const o=M(i);if(o!==void 0)return{vol:s,chap:o,slug:n}})}).flat().filter(Boolean).reverse();return z(e)}function ce({data:a,getTagIdsFromNames:e}){const{id:t,attributes:r,relationships:s}=a;if(!t||typeof t!="string"||typeof r!="object")return;const{title:n,availableTranslatedLanguages:i,altTitles:o,tags:l,contentRating:c}=r;if(typeof n!="object"||i&&!Array.isArray(i))return;const u=Object.values(n)[0];if(!u||typeof u!="string")return;const d=Dt(),h=(i??[])?.map?.(f=>typeof f=="string"?f:void 0).filter(Boolean)??[],p=h.filter(f=>f&&(!d||d.includes(f))),v=o?.map?.(f=>{const[[,C]=[]]=Object.entries(f);return C}),y=s?.find?.(f=>f.type==="cover_art")?.attributes?.fileName,w=y?`https://mangadex.org/covers/${t}/${y}.256.jpg`:void 0,b=(l||[]).map(f=>f?.attributes?.name?.en).concat(c).filter(Boolean);return{url:`${location.origin}/title/${t}`,slug:t,name:u,altNames:v,langs:p.length>0?p:h.length>0?h:["en"],img:w,tags:e(b)}}function Dt(){const a=localStorage.getItem("md");if(a)try{const e=JSON.parse(a)?.userPreferences?.filteredLanguages;return e?.length?e:void 0}catch{return}}var Tt=Object.defineProperty,Ct=(a,e,t)=>e in a?Tt(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,Pt=(a,e,t)=>(Ct(a,typeof e!="symbol"?e+"":e,t),t);class ue extends m{async getRawReleasesData(){const e=await super.getRawReleasesData();if(e)return{...e,rawReleases:e.rawReleases.map(t=>({...t,id:t.id?.split("?")[0]}))}}async getRawReaderData(){if((await I(".current-viewtype",{lazy:!0,all:!1}))?.textContent?.trim().toLowerCase()!=="volume")return await super.getRawReaderData()}async getRawChaptersData(){const{lang:e}=this.context;if(!e)return;const t=await I(`.tab-content[data-name="chapter"] a.dropdown-item[data-code="${e.toUpperCase()}"]`,{lazy:!0,all:!1});if(t)return t.click(),await I(`.tab-content[data-name="chapter"] li.item[data-number] a[href*="/${e}/"]`,{lazy:!0,all:!1}),await super.getRawChaptersData()}}Pt(ue,"specId","mangafire");var Bt=Object.defineProperty,jt=(a,e,t)=>e in a?Bt(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,Lt=(a,e,t)=>(jt(a,typeof e!="symbol"?e+"":e,t),t);class ge extends m{async getRawReaderData(){const e=await super.getRawReaderData();return e&&{...e,imgs:await this.getImgs()}}parseReaderSlug(e,t){const{slug:r,basePath:s}=super.parseReaderSlug(e,t),n=r.split("/").filter(Boolean),i=n[n.length-1];return{basePath:s,slug:i.startsWith("pg-")?n.slice(0,-1).join("/"):r}}async getImgs(){const e=await N(100,20,()=>window.imgsrcs),t=window.CryptoJS,r=t.enc.Hex.parse("e11adc3949ba59abbe56e057f20f883e"),s={iv:t.enc.Hex.parse("1234567890abcdef1234567890abcdef"),padding:t.pad.ZeroPadding};return t.AES.decrypt(e,r,s).toString(t.enc.Utf8).split(",")}}Lt(ge,"specId","mangago");var Ot=Object.defineProperty,Nt=(a,e,t)=>e in a?Ot(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,_t=(a,e,t)=>(Nt(a,typeof e!="symbol"?e+"":e,t),t);class de extends m{async getRawTitleData(){const e=await super.getRawTitleData();return e&&{...e,chapters:e.chapters.map(t=>({...t,slug:t.slug?.split("/").filter(Boolean).slice(-1)[0]}))}}}_t(de,"specId","mangaplus");var zt=Object.defineProperty,At=(a,e,t)=>e in a?zt(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,kt=(a,e,t)=>(At(a,typeof e!="symbol"?e+"":e,t),t);class he extends m{async getRawReleasesData(){const e=await super.getRawReleasesData();if(e)return{...e,rawReleases:e.rawReleases.map(t=>({...t,id:t.slug.substring(t.slug.lastIndexOf("-")+1)||void 0}))}}}kt(he,"specId","mangareader");var Wt=Object.defineProperty,Et=(a,e,t)=>e in a?Wt(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,Ut=(a,e,t)=>(Et(a,typeof e!="symbol"?e+"":e,t),t);class pe extends q{async getRawReaderData(){const e=await super.getRawReaderData();if(e)return{...e,title:{...e.title,id:await this.getReaderTitleId()}}}async getReaderTitleId(){const e=await window.HISTORY?.getStored?.();if(!e||typeof e!="object")return;const t=Object.values(e).filter(Boolean);if(!t.length)return;t.sort((s,n)=>n.time-s.time);const r=t[0].manga_ID;return typeof r=="string"?r:typeof r=="number"?r+"":void 0}detectNewSiteMeta(e,t){if(this.siteId==="realm"||!e)return;const r={...t,releases:ne(location.pathname,"/")},s=e.title,n=document.querySelector(s.sel)??void 0;if(!n)return;const i=x(g(s.url,n));if(i===void 0)return;const o=n.querySelector(s.chapter.sel)??void 0;if(!(!o||x(g(s.chapter.url,o))===void 0))return r.titleBase=this.extractBasePath(i),t.titleIdType===E.id&&(g(s.id,n)||(t.titleIdType=E.name)),this.finalizeNewSiteMeta(t,r)}finalizeNewSiteMeta(e,t){if(this.siteId==="realm")return;const r=Object.keys(t),s={...e};let n=!1;return r.forEach(i=>{const o=t[i];o!==e[i]&&(s[i]=o,n=!0)}),n?s:void 0}}Ut(pe,"specId","mangastream");var qt=Object.defineProperty,Ft=(a,e,t)=>e in a?qt(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,Vt=(a,e,t)=>(Ft(a,typeof e!="symbol"?e+"":e,t),t);class fe extends m{async getRawReaderData(){const e=await super.getRawReaderData();if(e)return{...e,title:{...e.title,name:e.title.name.replace("Ritorna a","").trim()}}}}Vt(fe,"specId","mangaworld");var Ht=Object.defineProperty,Qt=(a,e,t)=>e in a?Ht(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,Jt=(a,e,t)=>(Qt(a,typeof e!="symbol"?e+"":e,t),t);class me extends m{async getRawTitleData(){const e=await super.getRawTitleData();if(e)return{...e,hasMoreChapters:e.chapters.length===50}}}Jt(me,"specId","mgeko");var Yt=Object.defineProperty,Zt=(a,e,t)=>e in a?Yt(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,Gt=(a,e,t)=>(Zt(a,typeof e!="symbol"?e+"":e,t),t);class we extends m{async getRawTitleData(){const e=await super.getRawTitleData();if(!e)return;const t=_(".info-detail__row > .genre-btn,.info__right .stats__row:first-child|text")?.map(r=>[r,...r.split(" ")]).flat();return ve({...e,tags:this.getTagIdsFromNames(t)??[]},".episode-header .episode-cnt")}async getRawReaderData(){const e=await super.getRawReaderData();if(!e)return;const t=`${location.origin}/series/${e.title.slug}/info`;return{...e,title:{...ve({...e.title,url:t,tags:[]},".episode-list .js-ep-cnt"),hasMoreChapters:!1}}}async getRawChaptersData(){const{rawId:e,skip:t}=this.context,r=1e3,s=t?Math.floor(t/1e3)+1:1;try{const n=await fetch(`/series/${e}/episodes?page=${s}&sort=NEWEST&max_limit=${r}`);return Kt(await n.json())}catch{return}}parseTitleSlug(e){if(!e)return{};const t=e.split("/").filter(Boolean);return{slug:t[1]??t[0]}}}Gt(we,"specId","tapas");function ve(a,e){const t=Xt(e)>20;return{...a,chapters:t?[]:a.chapters,hasMoreChapters:t}}function Kt(a){const e=a?.data?.episodes;if(!Array.isArray(e))return;const t=e.map(s=>({chap:s.pending_scene??s.scene,slug:s.id+"",ts:new Date(s.publish_date)?.valueOf?.()||void 0})),r=a?.data?.pagination;return{chapters:t,total:r?.total??t.length,hasMore:!!r?.has_next}}function Xt(a){return+(document.querySelector(a)?.textContent?.trim().split(" ")[0]||0)}var ea=Object.defineProperty,ta=(a,e,t)=>e in a?ea(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,aa=(a,e,t)=>(ta(a,typeof e!="symbol"?e+"":e,t),t);class ye extends m{async getRawReleasesData(){const e=await super.getRawReleasesData();if(e)return{...e,rawReleases:e.rawReleases.map(t=>({...t,id:ra(t.slug)}))}}}aa(ye,"specId","truyenqq");function ra(a){return a.substring(a.lastIndexOf("-")+1).replace(".html","")||void 0}var sa=Object.defineProperty,na=(a,e,t)=>e in a?sa(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,ia=(a,e,t)=>(na(a,typeof e!="symbol"?e+"":e,t),t);class be extends m{async getRawTitleData(){const e=await super.getRawTitleData();return e?.img?{...e,img:oa(e.img)}:e}getRawReaderTitleData(){const e=super.getRawReaderTitleData();if(e)return{...e,name:e.name.split(" Chapter")[0]}}async getRawChaptersData(){const e=await this.getRawTitleData();if(!e)return;const t=T(location.origin,"api","chapters"),r=document.querySelector('button[data-key="chapters"]');if(!r)return;r.click();const s=setInterval(()=>r.click(),100),n=await t;if(clearInterval(s),!n?.value)return;const i=n.url.split("?")[1];if(!i)return;const o=new URLSearchParams(i).get("postId");if(!o)return;const l=n.value?.totalChapterCount;if(!l||l<50){const d=Re(n.value);return d?{chapters:d,title:e,hasMore:!1,skip:0,total:l}:void 0}const c=await fetch(`${location.origin}/api/chapters?postId=${o}&skip=0&take=1000&order=desc`),u=Re(await c.json());if(u)return{chapters:u,title:e,total:l,skip:0,hasMore:!1}}}ia(be,"specId","vortex");function oa(a){try{return new URL(a,location.href).searchParams.get("url")||a}catch{return a}}function Re(a){const e=a?.post?.chapters;if(e)return e.map(t=>({slug:t.slug,chap:t.number,ts:t.createdAt?new Date(t.createdAt)?.valueOf?.():void 0})).filter(t=>t.slug&&typeof t.chap=="number")}var la=Object.defineProperty,ca=(a,e,t)=>e in a?la(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,ua=(a,e,t)=>(ca(a,typeof e!="symbol"?e+"":e,t),t);class Se extends m{async getRawTitleData(){const e=new URLSearchParams(location.search),t=e.get("episode_no"),r=e.get("title_no");if(t||!r)return;const s=await super.getRawTitleData();if(!s)return;const n=location.pathname.split("/")[1];return{...s,slug:`${s.slug}?title_no=${r}`,id:r,langs:[n].filter(Boolean),chapters:s.chapters.map(i=>({...i,lang:n})),hasMoreChapters:(document.querySelector(".paginate")?.childElementCount??1)>1}}async getRawReaderData(){const e=new URLSearchParams(location.search),t=e.get("episode_no"),r=e.get("title_no");if(!t||!r)return;const s=L(g(".paginate > span:not(:first-child)|text"));if(s===void 0)return;const{chap:n}=s,i=document.title.split("|")[1]?.trim();if(!i)return;const o=location.pathname.split("/"),l=`${o.slice(0,4).join("/")}/list?title_no=${r}`,c=await this.getChapters({sel:"#sequence_scroll li.eg-flick-panel,#toolbar .episode_lst li[data-episode-no]",url:"a|attr:href",label:"|attr:data-episode-no || .num|text"},{lazy:!1,titleId:r,titleSlug:l}),u=o[1];return{chap:n,lang:u,slug:`${location.pathname}?title_no=${r}&episode_no=${t}`,basePath:"",imgs:await this.getReaderImgs(),isWebtoon:!0,title:{id:r,url:l,slug:l,name:i,langs:[u],chapters:(c??[]).map(d=>({...d,lang:u})),hasMoreChapters:!1}}}async getReaderImgs(){const e=_("#_imageList img|[attr:data-url,attr:src]");return e?.length?e:await N(100,50,()=>window.__viewerState__?.scrollViewerParam?.imageList?.map(({url:t})=>t).filter(Boolean))}parseReaderSlug(e,t,r){if(!r)return{basePath:"",slug:t};if(r.startsWith("http://")||r.startsWith("https://")){const s=W(r);return{basePath:"",slug:s.pathname+s.search}}return{basePath:"",slug:r}}}ua(Se,"specId","webtoon");var ga=Object.defineProperty,da=(a,e,t)=>e in a?ga(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,ha=(a,e,t)=>(da(a,typeof e!="symbol"?e+"":e,t),t);class xe extends m{async getRawChaptersData(){const{rawId:e}=this.context;if(!e)return;const t=await pa(e);if(!t)return;const r=document.createElement("DIV");r.innerHTML=t;const s=await this.getChapters({sel:'a[href*="/chapters/"]',url:"|attr:href",label:"span span|text",at:"time|attr:datetime"},{root:r,lazy:!0});if(s)return{chapters:s,hasMore:!1,asc:!1,total:s.length}}}ha(xe,"specId","weebcentral");async function pa(a){const e=`https://weebcentral.com/series/${a}/full-chapter-list`;try{return await(await fetch(e)).text()}catch{return}}const fa=[te,ft,se,q,oe,ue,ge,de,he,pe,fe,me,we,be,ye,Se,xe];function $e(a){const e=fa.find(t=>t.specId===a.spec.id)??m;return new e(a)}async function ma(a){const{spec:e}=a;if(e){const t=a.siteMeta??e.meta,r=a.type?[a.type]:Ie(t,e.generic);if(!r.length)return;const s=$e({...a,spec:e,siteMeta:t});return await B(r.map(n=>s.getRawPageByType(n,r.length>1)))}return await B((a.genericSpecs??[]).map(t=>{const r=Ie(t.meta,t.generic);if(!r.length)return[];const s=$e({...a,spec:t,siteMeta:t.meta});return r.map(n=>s.getRawPageByType(n,!0))}).flat())}function Ie(a,e){if(location.pathname==="/")return[];const{titleBase:t,readerBase:r}=a,s=location.pathname.split("/").filter(Boolean),n=Me(s,r),i=Me(s,t);if(n&&i)return[S.reader,S.title];const o=[];return!i&&(n!==!1||e)&&o.push(S.reader),!n&&(i!==!1||e)&&o.push(S.title),!o.length&&e?[S.reader,S.title]:o}function Me(a,e){if(!e)return;const t=e.split("/").filter(Boolean),r=t.indexOf("{slug}"),s=r===t.length-1,n=!s&&r!==-1;if(s&&(t.pop(),!t.length))return;const i=a.length-t.length;if(n?i<0:i<=0)return!1;let o=!1;for(let l=0;l<t.length;l++){const c=t[l];if(c[0]!=="{"){if(c!==a[l])return!1;o=!0}}if(o&&i===(n?0:1))return!0}P.PageType=S,P.scrape=ma});
1
+ (function(P,B){typeof exports=="object"&&typeof module<"u"?B(exports):typeof define=="function"&&define.amd?define(["exports"],B):(P=typeof globalThis<"u"?globalThis:P||self,B(P._trackkun_={}))})(this,function(P){"use strict";function B(a){let t=!1;return new Promise((e,r)=>{Promise.all(a.map(async s=>{const n=await s;!t&&n&&(t=!0,e(n))})).then(()=>{t||e(void 0)})})}function W(a,{removeTrailingSlash:t=!0}={}){if(!a)return;const e=t&&a.endsWith("/")?a.slice(0,-1):a;try{return new URL(e)}catch{return}}function x(a){if(!(!a||typeof a!="string"))return a.startsWith("http://")||a.startsWith("https://")?W(a)?.pathname:a.startsWith("//")?W(`https:${a}`)?.pathname:a}async function N(a,t,e){const r=await e(()=>{a=0});if(r!==void 0)return r;if(!(a<=0))return await new Promise(s=>{setTimeout(async()=>{const n=await N(a-1,t,e);s(n)},t)})}async function I(a,t,e=0){const r=t.root??document.documentElement,s=t.timeoutMs??1e4;return N(t.lazy===!0?s/50:0,50,()=>{const n=t.all===!0?Array.from(r.querySelectorAll(a)):r.querySelector(a)??void 0;return(t.all?!n?.length:!n)?void 0:n})}const Q={text:jt,attr:Lt,"attr-contain":Ot,value:Nt,row:_t,"bg-image":zt};function g(a,t){if(a)return J(a,t,Pt)}function _(a,t){if(a)return J(a,t,Bt)}function J(a,t,e){if(!a)return;const r=a.split("||").map(s=>s.trim()).filter(s=>!!s&&s.includes("|"));for(const s of r){const n=Ct(s);if(!n)continue;const i=e(t??document.documentElement,n.selector,n.instructions);if(i)return i}}function Ct(a){const[t,e]=a.split("|");if(!e)return;const r=(e?.startsWith("[")&&e.endsWith("]")?e.substring(1,e.length-1).split(","):[e]).map(s=>{const n=s.indexOf(":"),i=n!==-1;return{extractor:i?s.substring(0,n):s,param:i?s.substring(n+1):""}});return{selector:t||void 0,instructions:r}}function Pt(a,t,e){if(!t)return Y(a,e);const r=t.split(",");for(const s of r){const n=Array.from(a.querySelectorAll(s));for(const i of n){const o=Y(i,e);if(o)return o}}}function Bt(a,t,e){const r=t?Array.from(a.querySelectorAll(t)):[a],s=[];for(const n of r)for(const i of e){const o=Q[i.extractor],l=o(n,i.param);if(l){s.push(l);break}}if(s.length)return s}function Y(a,t){for(const e of t){const r=Q[e.extractor],s=r(a,e.param);if(s)return s}}function jt(a){return Array.from(a.childNodes).filter(t=>t.nodeType===3).map(t=>j(t.textContent)).filter(Boolean).join(" ").trim()||j(a.textContent)}function Lt(a,t){return j(a.getAttribute(t))}function Ot(a,t){let e=a.getAttribute(t);if(!e){const r=a.getAttributeNames().find(s=>s.includes(t));r&&(e=a.getAttribute(r))}return j(e)}function Nt(a){return a.value}function _t(a,t){if(!t)return;const e=j(a.textContent)?.toLowerCase(),r=t.toLowerCase();if(!(e!==r&&e!==`${r}:`))return j(a.nextElementSibling?.textContent??a.nextSibling?.textContent)}function zt(a){const t=getComputedStyle(a).backgroundImage;if(!(!t||!t.startsWith("url(")))return t.slice(5,-2)||void 0}function j(a){if(a)return a?.replace(/(\n|\t)/g," ").trim()||void 0}var At=(a=>(a[a.reading=1]="reading",a[a.paused=2]="paused",a[a.plan=3]="plan",a[a.completed=4]="completed",a[a.dropped=5]="dropped",a[a.deleted=6]="deleted",a))(At||{}),kt=(a=>(a[a.ok=1]="ok",a[a.hidden=2]="hidden",a[a.deleted=3]="deleted",a))(kt||{}),Wt=(a=>(a[a.aggregator=0]="aggregator",a[a.scanlator=1]="scanlator",a))(Wt||{}),Et=(a=>(a[a.pending=0]="pending",a[a.completed=1]="completed",a[a.offline=2]="offline",a[a.incompat=3]="incompat",a))(Et||{}),E=(a=>(a.id="id",a.name="name",a.slug="slug",a))(E||{}),A=(a=>(a.blank="about:blank",a.title="meta.title",a.reader="meta.reader",a))(A||{});const Ut=/(vol(ume)?|season)(\s*|-|\.)(\d+)/i,qt=/^S([1-9])\s/i,Ft=/(ch(ap(t(er)?|\.)?|\.)?|^#|episode\.?|capitolo\.?|capitulo\.?|bölüm\.?)(\s*|-)(\d+([_-~,.]\d+)?)/i,Vt=/\d+([_-~,.]\d+)?/,Ht=/[_-~,]/;function Qt(a){const t=a.match(Ut);if(t)return{volStr:t[0],volValueStr:t[4]};const e=a.match(qt);return e?{volStr:e[0],volValueStr:e[1]}:{}}function L(a){if(!a)return;if(!isNaN(+a))return{chap:+a};const{volStr:t,volValueStr:e}=Qt(a),r=t?a.replace(t,"").trim():a,s=r.match(Ft),n=r.match(Vt),i=s?.[6],o=i??n?.[0];if(!o)return;const l=+o.replace(Ht,".");return isNaN(l)?void 0:{vol:t&&e&&!isNaN(+e)&&a.indexOf(t)<a.indexOf(i?s[0]:n[0])?+e:void 0,chap:l}}async function Z(a,t=240){return new Promise(e=>{const r=new Image;r.crossOrigin="anonymous",r.onerror=()=>e(void 0),r.onload=()=>{const s=document.createElement("canvas"),n=s.getContext("2d"),i=Math.max(1,r.naturalWidth/t),o=r.naturalWidth/i,l=r.naturalHeight/i;s.width=o,s.height=l;const c=/iPad|iPhone|iPod/.test(navigator.userAgent);try{n.drawImage(r,0,0,o,l);const u=s.toDataURL(c?"image/jpg":"image/webp",c?.99:.8).split(",").slice(-1)[0];e(u)}catch{e(void 0)}},r.src=a})}async function Jt(a,t=240){const e=await Yt(a);if(e)return await new Promise(async r=>{const s=Z(e,t),n=setTimeout(()=>r(void 0),100),i=await s;clearTimeout(n),r(i)})}async function Yt(a){try{const t=await fetch(a);if(t.status>=400)return;const e=await t.blob();return URL.createObjectURL(e)}catch{return}}function z(a){return a.sort((t,e)=>t.vol===void 0||e.vol===void 0?e.chap-t.chap:e.vol-t.vol||e.chap-t.chap),Zt(a)}function Zt(a){const t={};for(let r=a.length-1;r>=0;r--){const s=a[r],n=s.lang??"";s.vol!==void 0?t[n]=s.vol:t[n]!==void 0&&(s.inferVol=t[n])}const e=[];for(const r of a){const s=e[e.length-1];if(!(s&&s.chap===r.chap&&(s.vol===r.vol||s.vol===void 0||r.vol===void 0))){e.push(r);continue}s.vol===void 0&&r.vol!=null&&(e[e.length-1]=r)}return e}const Gt=[{seconds:1,locales:{en:"sec",vi:"gi\xE2y",tr:"ikinci",es:"segunda"}},{seconds:60,locales:{en:"min",vi:"ph\xFAt",tr:"dakika"}},{seconds:3600,locales:{en:"hour",vi:"gi\u1EDD",tr:"saat",fr:"heure",it:"ora",es:"hora"}},{seconds:86400,locales:{en:"day",vi:"ng\xE0y",tr:"g\xFCn",fr:"jour",it:"giorno",es:"d\xEDa"}},{seconds:604800,locales:{en:"week",vi:"tu\u1EA7n",tr:"hafta",fr:"semaine",it:"settimana",es:"semana"}},{seconds:2592e3,locales:{en:"month",vi:"th\xE1ng",tr:"ay",fr:"mois",it:"mese",es:"mes"}},{seconds:31536e3,locales:{en:"year",vi:"n\u0103m",tr:"yil",fr:"an",it:"anno",es:"a\xF1o"}}];function G(a,t){const e=a?.toLowerCase();if(!e)return;const r=Date.now();if(e.includes("now"))return r;if(e.includes("yesterday"))return r-864e5;const s=new Date(e);if(s instanceof Date){const c=s.valueOf();if(!isNaN(c))return s.getHours()===0&&s.getMinutes()===0?Math.min(r,c+432e5):c}const n=Gt.find(c=>t&&c.locales[t]&&e.indexOf(c.locales[t])!==-1?!0:e.indexOf(c.locales.en)!==-1);if(!n)return;const i=e.split(" ").filter(Boolean),o=K(i)??(t==="en"?K(i,["a","an"]):void 0);if(!o)return;const l=r-o*n.seconds*1e3;return l>0?l:void 0}function K(a,t){for(let e=0;e<a.length;e++){const r=a[e];if(t?.includes(r))return 1;const s=+r;if(s)return s<0?void 0:s}}function X(a,t=location.origin){if(!a)return;const e=new URL(a.startsWith("//")?`${location.protocol}${a}`:a,location.origin+location.pathname).toString();return e.startsWith(t)?e.replace(t,""):e}function tt(a,{titleSlug:t,titleId:e}){if(!a)return"/";let r=a.replace("{titleSlug}",t);e&&(r=r.replace("{titleId}",e));const s=r.endsWith("/")?r:r+"/";return s.startsWith("/")?s:"/"+s}function Kt(a,t){const e=[...t],r=[];let s=!1,n=0;const i=Math.min(a.length,100);for(let l=0;l<i;l++){if(n>=10/2){const p=10-r.length;if(p>0){const v=l+p<=a.length?a.slice(l,l+p):e.slice(0,p);r.push(...v)}break}const c=a[l],u=c.id!==void 0,d=e.findIndex(p=>u&&p.id===c.id||p.slug===c.slug||p.name==c.name),h=d===-1?void 0:e.splice(d,1)[0];!h||h.chapters[0]?.chap!==c.chapters[0]?.chap?(s=!0,r.push({...c,changed:!0})):(n++,r.push(c))}if(!s)return{hasMore:!1,rawReleases:[]};if(r.length<=10)return{hasMore:!!a[a.length-1]?.changed,rawReleases:r};const o=[];for(let l=0;l<r.length;l++){const c=r[l];(c.changed||l<10)&&o.push(c)}return{hasMore:t.length<2||t.length-e.length<2,rawReleases:o}}function Xt(a,t){const e={};return a.forEach(r=>{const s=r.chapters.reduce((n,i)=>{const o=i.lang||t||"";return n[o]||(n[o]=[]),n[o].push(i),n},{});Object.entries(s).forEach(([n,i])=>{const o=`${r.slug}:${n}`;e[o]?(e[o].chapters.push(...i),z(e[o].chapters)):e[o]={...r,lang:n===""?void 0:n,chapters:i}})}),Object.values(e)}var S=(a=>(a.title="title",a.reader="reader",a.releases="releases",a.chapters="chapters",a.search="search",a))(S||{}),te=Object.defineProperty,ee=(a,t,e)=>t in a?te(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e,$=(a,t,e)=>(ee(a,typeof t!="symbol"?t+"":t,e),e);class k{constructor(t){$(this,"headless"),$(this,"siteId"),$(this,"spec"),$(this,"siteMeta"),$(this,"tags"),$(this,"context"),$(this,"methodsMap",{[S.title]:()=>this.getRawTitleData(),[S.reader]:()=>this.getRawReaderData(),[S.releases]:()=>this.getRawReleasesData(),[S.search]:()=>this.getRawSearchData(),[S.chapters]:()=>this.getRawChaptersData()}),$(this,"normalizedTagsMap"),this.siteId=t.siteId,this.spec=t.spec,this.siteMeta=t.siteMeta,this.tags=t.tags,this.context=t.context??{},this.headless=t.headless===!0}async getRawSearchData(){throw new Error("Unimplemented")}async getRawPageByType(t,e=!1){const r=await this.methodsMap[t](),s=!r&&(t===S.title||t===S.reader)&&await re(this.spec);if(e&&!r&&!s)return;const n=location.origin+location.pathname;return{type:t,is404:s,specId:this.spec.id,siteName:g(this.spec.name),url:n,data:r,spec:this.spec,context:this.context}}parseReaderSlug(t,e,r){let s=e;if(s[0]!=="/"&&s.includes("/"))try{s=new URL(e,location.href).pathname}catch{}const n=s.endsWith("/")?s.slice(0,-1):s;if(t.includes("{")){const i=t.split("/").filter(Boolean),o=n.split("/").filter(Boolean);if(i.length<o.length){const l=o[i.indexOf("{lang}")],c=o[i.indexOf("{titleId}")],u=o[i.indexOf("{titleSlug}")],d=t.replace("{lang}",l).replace("{titleId}",c).replace("{titleSlug}",u);if(n.startsWith(d))return{basePath:d,lang:l.toLowerCase(),titleId:c,titleSlug:u,slug:n.replace(d,"")}}}else if(n.startsWith(t))return{basePath:t,slug:n.replace(t,"")};return{basePath:"",slug:n[0]==="/"?n.substring(1):n}}parseTitleSlug(t){if(typeof t!="string")return{};const e=x(t),r=e?.split("/").filter(Boolean);if(!r?.length)return{};const s=this.siteMeta.titleBase.split("/").filter(Boolean),n=s.indexOf("{slug}");return(n===-1?r.length-s.length>=1:r.length===s.length)?{id:r[s.indexOf("{id}")],slug:n===-1?r.slice(s.length).join("/"):r[n]}:{slug:e}}finalizeRawReleasesData(t){const e=this.spec.releases?.title?.lang?this.siteMeta.defaultLang:void 0,r=Xt(t.rawReleases,e);if(r.length)return this.context.oldRawReleases?Kt(r,this.context.oldRawReleases):{rawReleases:r,hasMore:!0}}getTagIdsFromNames(t){if(!t?.length)return;const e=this.normalizedTagsMap??(this.normalizedTagsMap=ae(this.tags)),r=t.map(s=>e[U(s)]).filter(Boolean);return r.length===0?void 0:Array.from(new Set(r)).sort((s,n)=>s-n)}}$(k,"specId"),$(k,"siteId");function ae(a){const t={};return a.forEach(({id:e,name:r,altNames:s})=>{t[U(r)]=e,s&&s.forEach(n=>{t[U(n)]=e})}),t}function U(a){const t=a.toLowerCase().replaceAll(" ","").replaceAll("-","");return t[t.length-1]==="s"?t.substring(0,t.length-1):t}async function re(a){return se()===404||a[404]&&await I(a[404],{lazy:!0,timeoutMs:5e3})?!0:document.title.toLowerCase().includes("not found")}function se(){try{return window.performance.getEntries().find(a=>a.entryType==="navigation")?.responseStatus}catch{return}}class m extends k{async getRawReleasesData(){if(!this.spec?.releases?.title)return;const{chapter:t,...e}=this.spec.releases.title,r=await I(e.sel,{lazy:!0,all:!0});if(!r?.length)return;const s=r.slice(0,100).map(i=>{const o=g(e.url,i),l=x(o),c=g(e.name,i),u=g(e.at,i);if(!(!l||!c))return{titleEl:i,id:g(e.id,i),path:l,name:c,lang:g(e.lang,i)?.toLowerCase(),at:G(u,this.siteMeta.defaultLang)}}).filter(Boolean);if(!s.length)return;const n=[];return await Promise.all(s.map(async i=>{const{path:o,titleEl:l,lang:c,at:u,...d}=i,{id:h,slug:p}=this.parseTitleSlug(o);if(!p)return;const v=d.id||h,y=await this.getChapters(t,{root:l,titleId:v,titleSlug:p})??[];y.length&&n.push({slug:p,chapters:c||u?y.map(w=>({...w,elIndex:void 0,lang:w.lang??c,ts:w.ts??u})):y,...d,id:v})})),this.finalizeRawReleasesData({rawReleases:n})}getRawTitleData(){return this.getTitleData(this.spec.title)}async getTitleData(t){if(!t||(t.sel||t.lazy)&&!await I(t.sel??t.name,{lazy:!!t.lazy}))return;const e=g(t.name);if(!e)return;const{id:r,slug:s}=this.parseTitleSlug(location.pathname);if(!s)return;const n=_(t.tags)?.map(h=>h.split(",")).flat().map(h=>h.trim()).filter(Boolean),i=g(t.type),o=_(t.langs)?.map(h=>h.toLowerCase()),l=r||g(t.id),c=await this.getChapters(t.chapter,{lazy:!0,titleId:l,titleSlug:s})??[],u=t.img?await this.getValidImgSrc(t.img):void 0,d=u&&this.context.includeImgBytes?await Jt(u):void 0;return{id:l||g(t.id),url:location.origin+location.pathname,slug:s,name:e,langs:o?.length?o:t.langs&&this.siteMeta.defaultLang?[this.siteMeta.defaultLang]:void 0,tags:this.getTagIdsFromNames([...n??[],...i?[i]:[]]),chapters:c,hasMoreChapters:t.hasMore?!!document.querySelector(t.hasMore):void 0,img:u,imgBytes:d,firstUrl:this.getFirstChapterUrl()}}getFirstChapterUrl(){const t=g(this.spec.title?.first);if(t){if(t.startsWith("http"))return t;try{return new URL(t,location.href).href}catch{return}}}getValidImgSrc(t){return N(33,30,()=>{const e=g(t);return e&&!e.startsWith("data:")?e.split(" ")[0]:void 0})}getRawReaderTitleData(){const t=this.spec.reader?.title;if(!t)return;const e=t.sel?document.querySelector(t.sel)??void 0:void 0,r=g(t.name,e),s=g(t.url,e),{slug:n,id:i}=this.parseTitleSlug(s),o=X(g(t.img,e));if(!(!r||!s||!n))return{name:r,img:o,url:s,slug:n,id:i||g(t.id)}}async getRawReaderData(){const{spec:t,siteMeta:e}=this;if(!t?.reader||t.generic&&!await m.isReaderPage(t.reader))return;const r=t.reader.content;if(!(!r||await m.verifyImgsCotainer(r)))return;const s=this.getRawReaderTitleData();if(!s)return;const{id:n,slug:i}=s,o=t.reader?.chapter,l=!!this.context.disableLazyChapters,c=!!this.context.includeHiddenChapters,u=await this.getChapters(o,{titleId:n,titleSlug:i,lazy:c||!l,includeHiddenChapters:c,timeoutMs:c?3e3:29e3,includeIndex:!0})??[],d=g(t.reader.label)?.toLowerCase().replace(s.name.toLowerCase(),"");if(!d)return;const{vol:h,chap:p=0}=L(d)||{},{slug:v,basePath:y,lang:w,titleId:b}=this.parseReaderSlug(tt(e.readerBase,{titleId:n,titleSlug:i}),location.pathname,location.href),f=this.findNeighborChapter({sel:t.reader.prev,basePath:y}),C=this.findNeighborChapter({sel:t.reader.next,basePath:y});return this.finalizeRawReaderData({vol:h,chap:p,lang:w??g(t.reader.lang)?.toLowerCase()??(t.reader.lang?this.siteMeta.defaultLang:void 0),slug:v,basePath:y,imgs:_(t.reader.imgs),title:{id:n||b||g(this.spec.reader?.title.id),url:s.url,slug:i,name:s.name,langs:w?[w]:void 0,img:s.img,chapters:u,hasMoreChapters:!u.length&&!c&&!!this.context.disableLazyChapters&&!!o?.label}},{prevSlug:f,nextSlug:C})}async getRawChaptersData(){const t=this.siteMeta.chapters;if(t===A.blank)return;const e=t===A.reader,r=!t||t===A.title,s=e?(await this.getRawReaderData())?.title:r?await this.getRawTitleData():void 0;let n=s?.chapters;if(!e&&!r&&(n=await this.getChapters(this.spec.chapters?.chapter,{lazy:this.spec.chapters?.lazy})),!n)return;const{lang:i}=this.context,o=i?n.filter(l=>!l.lang||l.lang===i):n;return{chapters:o,title:s?{...s,chapters:[]}:await this.getTitleData(this.spec.chapters?.title),hasMore:!1,asc:!1,total:o.length}}async getRawSearchData(){const t=this.spec.search?.title;if(!t)return;const{chapter:e}=t,r=[];return await Promise.all(Array.from(document.querySelectorAll(t.sel)).map(async s=>{const n=g(t.url,s),i=x(n),o=g(t.name,s),{slug:l,id:c}=this.parseTitleSlug(i);!i||!o||!l||r.push({id:c,slug:l,name:o,chapters:await this.getChapters(e,{root:s,titleId:c,titleSlug:l})??[]})})),r.length?{rawReleases:r}:void 0}async getChapters(t,{root:e,titleId:r="",titleSlug:s="",includeHiddenChapters:n=!1,lazy:i=!0,timeoutMs:o,includeIndex:l}={}){if(!t||!t.sel||!t.label)return;let c=null;if(t.trigger){if(!n||(c=document.querySelector(t.trigger),!c))return;c.click()}const u=[],d=await I(t.sel,{root:e,all:!0,lazy:i,timeoutMs:o});if(!d?.length)return c?.click(),[];const h=(d??[]).map((b,f)=>({id:g(t.id,b),label:g(t.label,b),url:g(t.url,b),at:g(t.at,b),elIndex:f}));c?.click();const p=h.map(({label:b})=>L(b)),v=p[1]?.chap;!p[0]&&(v===void 0||v<=1)&&(p[0]={chap:0});const{readerBase:y}=this.siteMeta,w=tt(y,{titleId:r,titleSlug:s});return p.forEach((b,f)=>{if(!b)return;const{id:C,url:D,at:F,elIndex:V}=h[f],R={...b,id:C,ts:G(F,this.siteMeta.defaultLang)};l&&(R.elIndex=V);const Dt=D?.startsWith("http")&&!D.includes(`//${location.hostname}/`),H=Dt?D:x(D);if(!H){u.push(R);return}if(Dt){u.push({...R,slug:H});return}const{slug:wa,lang:va}=this.parseReaderSlug(w,H,D);u.push({...R,slug:wa,lang:va})}),z(u)}static async isReaderPage(t){return!!t.sel&&!!await I(t.sel,{lazy:!!t.lazy})}static async verifyImgsCotainer(t){const e=t.split(",").map(r=>r.trim()).filter(Boolean).map(r=>`${r} img, ${r} canvas`).join(",");return!!await I(e,{lazy:!0,all:!1})}findNeighborChapter({sel:t,basePath:e}){const r=g(t);if(!r||r.startsWith("#")||r.startsWith("/#"))return;const s=x(r);if(s)return this.parseReaderSlug(e,s,r).slug||void 0}finalizeRawReaderData(t,{prevSlug:e,nextSlug:r}={}){const s=t.title.chapters;if(!s.length){const c=L(e),u=L(r);return!c&&!u?t:{...t,prev:c?{...c,slug:e}:void 0,next:u?{...u,slug:r}:void 0}}let n,i,o,l;for(let c=0;c<s.length&&!(n&&(!e||o)&&!r&&l);c++){const u=s[c];!n&&(t.slug==u.slug||t.chap===u.chap&&(t.vol===u.vol||t.vol===void 0))?(n=u,i=c):!o&&e===u.slug?o=u:!l&&r===u.slug&&(l=u)}return i!==void 0&&(o??(o=s[i+1]),l??(l=s[i-1])),{...t,inferVol:n?.inferVol,prev:o,next:l}}}var ne=Object.defineProperty,ie=(a,t,e)=>t in a?ne(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e,oe=(a,t,e)=>(ie(a,typeof t!="symbol"?t+"":t,e),e);class et extends m{parseTitleSlug(t){return{slug:x(t)?.split("/").filter(Boolean)[1]}}async getRawTitleData(){if(!(!this.headless&&navigator.userAgent.toLowerCase().includes("android")))return await super.getRawTitleData()}}oe(et,"specId","bato");function le(){return Math.random().toString(16).slice(2)}async function ce({addListener:a,removeListener:t,transform:e,filter:r,handler:s,onTimeout:n,timeout:i,once:o}){return new Promise(l=>{a(d);const c=()=>o===!0&&t(d),u=i?setTimeout(()=>{c(),l(void 0),n?.()},i):void 0;async function d(h,...p){h=e?e(h):h,h!==void 0&&(!r||r(h,...p))&&(c(),l(h),s?.(h,...p),u&&clearTimeout(u))}})}async function ue(a){return(await ce({addListener:t=>window.addEventListener("message",t),removeListener:t=>window.removeEventListener("message",t),...a}))?.data}async function ge(a){const{receiverWindow:t,timeout:e,targetOrigin:r,event:s,args:n}=a,i={reqId:le(),event:s,args:n};return(t||window)?.postMessage(i,r??"*"),(await ue({filter:o=>o?.data?.resId===i.reqId,timeout:e??3e4,once:!0}))?.result}const O={isAny:!0};function T(a,...t){return ge({event:"tk:fetchResult",args:{baseUrl:a,segments:t}})}var de=Object.defineProperty,he=(a,t,e)=>t in a?de(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e,pe=(a,t,e)=>(he(a,typeof t!="symbol"?t+"":t,e),e);const at=class Tt extends m{async getRawReleasesData(){let t;try{const r=Array.from({length:2},async(s,n)=>{const i=`https://api.${location.host}/chapter?accept_erotic_content=true&page=${n+1}&order=new`;return(await fetch(i)).json()});t=(await Promise.all(r)).flat()}catch{return}const e=[];return t.forEach(r=>{const{vol:s,chap:n,hid:i,lang:o,updated_at:l,md_comics:c}=r,u=typeof n=="string"&&!isNaN(+n)?+n:void 0;typeof u=="number"&&e.push({id:c.hid,slug:c.slug,name:c.title,chapters:[{slug:i,vol:typeof s=="string"&&!isNaN(+s)?+s:void 0,chap:u,lang:o,ts:new Date(l).valueOf()}]})}),super.finalizeRawReleasesData({rawReleases:e})}async getRawTitleData(){const t=await super.getRawTitleData();if(!t)return t;const e=await T(`https://api.${location.host}`,"comic",O,"chapters");if(!e)return t;const r=e.url.split("/").filter(Boolean).slice(-2)[0],s=rt(e.value),n=g("h1 ~ div.text-sm span:first-child|row:demographic"),i=n?this.getTagIdsFromNames([n])?.[0]:void 0;return i&&!t.tags?.includes(i)&&(t.tags?.push(i),t.tags?.sort((o,l)=>o-l)),{...t,img:t.img??X(g(this.spec.title?.img)),id:r,hasMoreChapters:s?.hasMore??!1,chapters:s?.chapters??[]}}async getRawReaderData(){const t=await super.getRawReaderData();return t&&{...t,lang:t.lang&&t.lang?.length<=6?t.lang:Tt.getLangFromReaderSlug(t.slug)||t.lang}}static getLangFromReaderSlug(t){const e=t.split("-");let r;for(let s=e.length-1;s>0;s--){const n=e[s];if(!isNaN(+n))break;r=r?`${n}-${r}`:n}return r&&r.length<=6?r:void 0}async getRawChaptersData(){if(!this.context.rawId)return;const{rawId:t,lang:e="en",skip:r}=this.context,s=r?Math.floor(r/1e3)+1:void 0;try{const n=await fetch(`https://api.${location.host}/comic/${t}/chapters?lang=${e}&limit=1000${s&&s>1?`&page=${s}`:""}`),i=rt(await n.json());return i?{...i,lang:e,asc:!1}:void 0}catch{return}}};pe(at,"specId","comick");let fe=at;function rt(a){if(!Array.isArray(a?.chapters))return;const t=[];return a.chapters.forEach(e=>{const{vol:r,chap:s,hid:n,lang:i,updated_at:o}=e,l=typeof s=="string"&&!isNaN(+s)?+s:void 0;typeof l!="number"||t.some(c=>c.vol==r&&c.chap===l&&c.lang===i)||t.push({slug:n,vol:typeof r=="string"&&!isNaN(+r)?+r:void 0,chap:l,lang:i,ts:new Date(o).valueOf()})}),{chapters:z(t),total:a.total??t.length,hasMore:a.total>a.limit}}var me=Object.defineProperty,we=(a,t,e)=>t in a?me(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e,ve=(a,t,e)=>(we(a,typeof t!="symbol"?t+"":t,e),e);class st extends m{async getRawChaptersData(){const t=this.context.titleSlug;if(!t)return;const e=`https://api.${location.host}/chapter/all/${t}`;return{chapters:(await(await fetch(e)).json()).map(ye).filter(Boolean)}}}ve(st,"specId","lua");function ye(a){if(!a||typeof a.chapter_name!="string")return;const t=L(a.chapter_name);if(t)return{...t,slug:typeof a.chapter_slug=="string"?a.chapter_slug:void 0,ts:typeof a.created_at=="string"?new Date(a.created_at).valueOf():void 0}}function nt(a,t){const e=a[0]===t?a.substring(1):a;return e[e.length-1]===t?e.substring(0,e.length-1):e}var be=Object.defineProperty,Re=(a,t,e)=>t in a?be(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e,Se=(a,t,e)=>(Re(a,typeof t!="symbol"?t+"":t,e),e);class q extends m{async getRawReleasesData(){const t=this.detectNewSiteMeta(this.spec.releases,this.siteMeta);this.siteMeta=t??this.siteMeta;const e=await super.getRawReleasesData();if(e)return{...e,siteMeta:t}}async getRawTitleData(){const t=this.finalizeNewSiteMeta(this.siteMeta,{titleBase:this.extractBasePath(location.pathname)});this.siteMeta=t??this.siteMeta;const e=await super.getRawTitleData();if(e)return{...e,siteMeta:t}}async getRawReaderData(){const t=it(this.spec.reader?.title);if(!t)return;const e=this.finalizeNewSiteMeta(this.siteMeta,{titleBase:this.extractBasePath(x(t))});this.siteMeta=e??this.siteMeta;const r=await super.getRawReaderData();if(r)return{...r,siteMeta:e}}async getRawSearchData(){const t=it(this.spec.search?.title);if(!t)return;const e=this.finalizeNewSiteMeta(this.siteMeta,{titleBase:this.extractBasePath(x(t))});this.siteMeta=e??this.siteMeta;const r=await super.getRawSearchData();if(r)return{...r,siteMeta:e}}detectNewSiteMeta(t,e){if(!t)return;const r=t.title,s=document.querySelector(r.sel)??void 0;if(!s)return;const n=x(g(r.url,s));if(n!==void 0)return this.finalizeNewSiteMeta(e,{titleBase:this.extractBasePath(n)})}finalizeNewSiteMeta(t,{titleBase:e}){if(t.titleBase!==e)return{...t,titleBase:e,readerBase:t.readerBase.replace(t.titleBase,e)}}extractBasePath(t){return nt(t,"/").split("/").slice(0,-1).join("/")}}Se(q,"specId","madara");function it(a){if(!a)return;const t=a.sel?document.querySelector(a.sel)??void 0:void 0;return g(a.url,t)}var xe=Object.defineProperty,$e=(a,t,e)=>t in a?xe(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e,Ie=(a,t,e)=>($e(a,typeof t!="symbol"?t+"":t,e),e);const Me={a:.1,b:.2,c:.3,d:.4};class ot extends k{parseTitleSlug(t){return{slug:x(t)?.split("/").filter(Boolean)[1]}}async getRawReleasesData(){let t=[];try{t=(await(await fetch("https://api.mangadex.org/chapter?limit=96&offset=0&includes[]=manga&contentRating[]=safe&contentRating[]=suggestive&contentRating[]=erotica&contentRating[]=pornographic&order[readableAt]=desc")).json()).data}catch{return}const e=[];return t.forEach(({relationships:r,attributes:s,id:n})=>{const i=r.find(({type:d})=>d==="manga"),o=M(s.volume),l=M(s.chapter);if(l===void 0)return;const{title:c}=i.attributes,u=c.en??Object.values(c)[0];e.push({slug:i.id,name:u,chapters:[{slug:s.externalUrl||n,vol:o,chap:l,lang:s.translatedLanguage,ts:new Date(s.readableAt).valueOf()}]})}),super.finalizeRawReleasesData({rawReleases:e})}async getRawTitleData(){const t="https://api.mangadex.org/manga/",[e,r]=await Promise.all([T(t,O),T(t,O,"feed")]);if(!e||!r)return;const s=r.value.data?.map?.(l=>{const{attributes:c,id:u}=l;if(typeof c!="object"||typeof u!="string"||!u)return;const{externalUrl:d,title:h,volume:p,chapter:v,translatedLanguage:y}=c;return{slug:d||u,label:h||void 0,vol:M(p),chap:M(v),lang:y||"en",ts:new Date(c.readableAt).valueOf()}}).filter(l=>l?.chap!=null)??[],{data:n}=e.value;if(!n)return;const i=ct({data:n,getTagIdsFromNames:l=>this.getTagIdsFromNames(l)});if(!i)return;const o=this.context.includeImgBytes&&i.img?await Z(i.img):void 0;return{...i,imgBytes:o,chapters:z(s),hasMoreChapters:(r.value.total||0)>(r.value.limit||0)}}async getRawReaderData(){const t="https://api.mangadex.org/",[e,r,s]=await Promise.all([T(t,"chapter",O),T(t,"at-home","server",O),T(t,"manga",O,"aggregate")]);if(!e||!r||!s)return;const n=e.value.data,{volume:i,chapter:o,externalUrl:l,translatedLanguage:c}=n.attributes||{},{baseUrl:u,chapter:{data:d,dataSaver:h,hash:p}}=r.value,v=n.relationships?.find?.(R=>R.type==="manga");if(!v)return;const y=ct({data:v,getTagIdsFromNames:R=>this.getTagIdsFromNames(R)});if(!y||typeof s.value.volumes!="object")return;const w=lt(s.value)??[];(typeof o!="string"||o==="none")&&!w.length&&w.push({chap:0,slug:n.id});const b=w.findIndex(R=>R.slug===n.id),f=n.relationships?.find?.(R=>R.type==="scanlation_group"),C=u.endsWith("/")?u:u+"/",D=!!localStorage.getItem("md")?.includes?.('"dataSaver":true'),F=`${C}${D?"data-saver":"data"}/`,V=((D?h:d)??[]).map?.(R=>`${F}${p}/${R}`)??[];return{externalUrl:l,vol:M(i),inferVol:w[b]?.inferVol,chap:M(o)||0,imgs:V,lang:c,slug:n.id,prev:w[b+1],next:w[b-1],basePath:"/chapter/",groupName:f?.attributes?.name,groupUrl:f?.attributes?.website,isWebtoon:v?.attributes?.tags?.some(R=>R.attributes.name.en==="Long Strip"),title:{...y,chapters:w}}}async getRawChaptersData(){const{titleSlug:t,lang:e="en"}=this.context;let r;try{const s=await fetch(`https://api.mangadex.org/manga/${t}/aggregate?translatedLanguage[]=${e}`);r=lt(await s.json())}catch{return}if(r)return{chapters:r,lang:e,asc:!1,hasMore:!1,total:r.length}}}Ie(ot,"specId","mangadex");function M(a){if(typeof a!="string"||a==="none")return;const t=parseFloat(a);if(t!==t)return;const e=a[a.length-1];return t+(Me[e]??0)}function lt(a){if(typeof a.volumes!="object")return;const t=Object.values(a.volumes).map(({volume:e,chapters:r})=>{const s=M(e);return Object.values(r).map(({id:n,chapter:i})=>{const o=M(i);if(o!==void 0)return{vol:s,chap:o,slug:n}})}).flat().filter(Boolean).reverse();return z(t)}function ct({data:a,getTagIdsFromNames:t}){const{id:e,attributes:r,relationships:s}=a;if(!e||typeof e!="string"||typeof r!="object")return;const{title:n,availableTranslatedLanguages:i,altTitles:o,tags:l,contentRating:c}=r;if(typeof n!="object"||i&&!Array.isArray(i))return;const u=Object.values(n)[0];if(!u||typeof u!="string")return;const d=De(),h=(i??[])?.map?.(f=>typeof f=="string"?f:void 0).filter(Boolean)??[],p=h.filter(f=>f&&(!d||d.includes(f))),v=o?.map?.(f=>{const[[,C]=[]]=Object.entries(f);return C}),y=s?.find?.(f=>f.type==="cover_art")?.attributes?.fileName,w=y?`https://mangadex.org/covers/${e}/${y}.256.jpg`:void 0,b=(l||[]).map(f=>f?.attributes?.name?.en).concat(c).filter(Boolean);return{url:`${location.origin}/title/${e}`,slug:e,name:u,altNames:v,langs:p.length>0?p:h.length>0?h:["en"],img:w,tags:t(b)}}function De(){const a=localStorage.getItem("md");if(a)try{const t=JSON.parse(a)?.userPreferences?.filteredLanguages;return t?.length?t:void 0}catch{return}}var Te=Object.defineProperty,Ce=(a,t,e)=>t in a?Te(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e,Pe=(a,t,e)=>(Ce(a,typeof t!="symbol"?t+"":t,e),e);class ut extends m{async getRawReleasesData(){const t=await super.getRawReleasesData();if(t)return{...t,rawReleases:t.rawReleases.map(e=>({...e,id:e.id?.split("?")[0]}))}}async getRawReaderData(){if((await I(".current-viewtype",{lazy:!0,all:!1}))?.textContent?.trim().toLowerCase()!=="volume")return await super.getRawReaderData()}async getRawChaptersData(){const{lang:t}=this.context;if(!t)return;const e=await I(`.tab-content[data-name="chapter"] a.dropdown-item[data-code="${t.toUpperCase()}"]`,{lazy:!0,all:!1});if(e)return e.click(),await I(`.tab-content[data-name="chapter"] li.item[data-number] a[href*="/${t}/"]`,{lazy:!0,all:!1}),await super.getRawChaptersData()}}Pe(ut,"specId","mangafire");var Be=Object.defineProperty,je=(a,t,e)=>t in a?Be(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e,Le=(a,t,e)=>(je(a,typeof t!="symbol"?t+"":t,e),e);class gt extends m{async getRawReaderData(){const t=await super.getRawReaderData();return t&&{...t,imgs:await this.getImgs()}}parseReaderSlug(t,e){const{slug:r,basePath:s}=super.parseReaderSlug(t,e),n=r.split("/").filter(Boolean),i=n[n.length-1];return{basePath:s,slug:i.startsWith("pg-")?n.slice(0,-1).join("/"):r}}async getImgs(){const t=await N(100,20,()=>window.imgsrcs),e=window.CryptoJS,r=e.enc.Hex.parse("e11adc3949ba59abbe56e057f20f883e"),s={iv:e.enc.Hex.parse("1234567890abcdef1234567890abcdef"),padding:e.pad.ZeroPadding};return e.AES.decrypt(t,r,s).toString(e.enc.Utf8).split(",")}}Le(gt,"specId","mangago");var Oe=Object.defineProperty,Ne=(a,t,e)=>t in a?Oe(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e,_e=(a,t,e)=>(Ne(a,typeof t!="symbol"?t+"":t,e),e);class dt extends m{async getRawTitleData(){const t=await super.getRawTitleData();return t&&{...t,chapters:t.chapters.map(e=>({...e,slug:e.slug?.split("/").filter(Boolean).slice(-1)[0]}))}}}_e(dt,"specId","mangaplus");var ze=Object.defineProperty,Ae=(a,t,e)=>t in a?ze(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e,ke=(a,t,e)=>(Ae(a,typeof t!="symbol"?t+"":t,e),e);class ht extends m{async getRawReleasesData(){const t=await super.getRawReleasesData();if(t)return{...t,rawReleases:t.rawReleases.map(e=>({...e,id:e.slug.substring(e.slug.lastIndexOf("-")+1)||void 0}))}}}ke(ht,"specId","mangareader");var We=Object.defineProperty,Ee=(a,t,e)=>t in a?We(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e,Ue=(a,t,e)=>(Ee(a,typeof t!="symbol"?t+"":t,e),e);class pt extends q{async getRawReaderData(){const t=await super.getRawReaderData();if(t)return{...t,title:{...t.title,id:await this.getReaderTitleId()}}}async getReaderTitleId(){const t=await window.HISTORY?.getStored?.();if(!t||typeof t!="object")return;const e=Object.values(t).filter(Boolean);if(!e.length)return;e.sort((s,n)=>n.time-s.time);const r=e[0].manga_ID;return typeof r=="string"?r:typeof r=="number"?r+"":void 0}detectNewSiteMeta(t,e){if(this.siteId==="realm"||!t)return;const r={...e,releases:nt(location.pathname,"/")},s=t.title,n=document.querySelector(s.sel)??void 0;if(!n)return;const i=x(g(s.url,n));if(i===void 0)return;const o=n.querySelector(s.chapter.sel)??void 0;if(!(!o||x(g(s.chapter.url,o))===void 0))return r.titleBase=this.extractBasePath(i),e.titleIdType===E.id&&(g(s.id,n)||(e.titleIdType=E.name)),this.finalizeNewSiteMeta(e,r)}finalizeNewSiteMeta(t,e){if(this.siteId==="realm")return;const r=Object.keys(e),s={...t};let n=!1;return r.forEach(i=>{const o=e[i];o!==t[i]&&(s[i]=o,n=!0)}),n?s:void 0}}Ue(pt,"specId","mangastream");var qe=Object.defineProperty,Fe=(a,t,e)=>t in a?qe(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e,Ve=(a,t,e)=>(Fe(a,typeof t!="symbol"?t+"":t,e),e);class ft extends m{async getRawReaderData(){const t=await super.getRawReaderData();if(t)return{...t,title:{...t.title,name:t.title.name.replace("Ritorna a","").trim()}}}}Ve(ft,"specId","mangaworld");var He=Object.defineProperty,Qe=(a,t,e)=>t in a?He(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e,Je=(a,t,e)=>(Qe(a,typeof t!="symbol"?t+"":t,e),e);class mt extends m{async getRawTitleData(){const t=await super.getRawTitleData();if(t)return{...t,hasMoreChapters:t.chapters.length===50}}}Je(mt,"specId","mgeko");var Ye=Object.defineProperty,Ze=(a,t,e)=>t in a?Ye(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e,Ge=(a,t,e)=>(Ze(a,typeof t!="symbol"?t+"":t,e),e);class wt extends m{async getRawTitleData(){const t=await super.getRawTitleData();if(!t)return;const e=_(".info-detail__row > .genre-btn,.info__right .stats__row:first-child|text")?.map(r=>[r,...r.split(" ")]).flat();return vt({...t,tags:this.getTagIdsFromNames(e)??[]},".episode-header .episode-cnt")}async getRawReaderData(){const t=await super.getRawReaderData();if(!t)return;const e=`${location.origin}/series/${t.title.slug}/info`;return{...t,title:{...vt({...t.title,url:e,tags:[]},".episode-list .js-ep-cnt"),hasMoreChapters:!1}}}async getRawChaptersData(){const{rawId:t,skip:e}=this.context,r=1e3,s=e?Math.floor(e/1e3)+1:1;try{const n=await fetch(`/series/${t}/episodes?page=${s}&sort=NEWEST&max_limit=${r}`);return Ke(await n.json())}catch{return}}parseTitleSlug(t){if(!t)return{};const e=t.split("/").filter(Boolean);return{slug:e[1]??e[0]}}}Ge(wt,"specId","tapas");function vt(a,t){const e=Xe(t)>20;return{...a,chapters:e?[]:a.chapters,hasMoreChapters:e}}function Ke(a){const t=a?.data?.episodes;if(!Array.isArray(t))return;const e=t.map(s=>({chap:s.pending_scene??s.scene,slug:s.id+"",ts:new Date(s.publish_date)?.valueOf?.()||void 0})),r=a?.data?.pagination;return{chapters:e,total:r?.total??e.length,hasMore:!!r?.has_next}}function Xe(a){return+(document.querySelector(a)?.textContent?.trim().split(" ")[0]||0)}var ta=Object.defineProperty,ea=(a,t,e)=>t in a?ta(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e,aa=(a,t,e)=>(ea(a,typeof t!="symbol"?t+"":t,e),e);class yt extends m{async getRawReleasesData(){const t=await super.getRawReleasesData();if(t)return{...t,rawReleases:t.rawReleases.map(e=>({...e,id:ra(e.slug)}))}}}aa(yt,"specId","truyenqq");function ra(a){return a.substring(a.lastIndexOf("-")+1).replace(".html","")||void 0}var sa=Object.defineProperty,na=(a,t,e)=>t in a?sa(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e,ia=(a,t,e)=>(na(a,typeof t!="symbol"?t+"":t,e),e);class bt extends m{async getRawTitleData(){const t=await super.getRawTitleData();return t?.img?{...t,img:oa(t.img)}:t}getRawReaderTitleData(){const t=super.getRawReaderTitleData();if(t)return{...t,name:t.name.split(" Chapter")[0]}}async getRawChaptersData(){const t=await this.getRawTitleData();if(!t)return;const e=T(location.origin,"api","chapters"),r=document.querySelector('button[data-key="chapters"]');if(!r)return;r.click();const s=setInterval(()=>r.click(),100),n=await e;if(clearInterval(s),!n?.value)return;const i=n.url.split("?")[1];if(!i)return;const o=new URLSearchParams(i).get("postId");if(!o)return;const l=n.value?.totalChapterCount;if(!l||l<50){const d=Rt(n.value);return d?{chapters:d,title:t,hasMore:!1,skip:0,total:l}:void 0}const c=await fetch(`${location.origin}/api/chapters?postId=${o}&skip=0&take=1000&order=desc`),u=Rt(await c.json());if(u)return{chapters:u,title:t,total:l,skip:0,hasMore:!1}}}ia(bt,"specId","vortex");function oa(a){try{return new URL(a,location.href).searchParams.get("url")||a}catch{return a}}function Rt(a){const t=a?.post?.chapters;if(t)return t.map(e=>({slug:e.slug,chap:e.number,ts:e.createdAt?new Date(e.createdAt)?.valueOf?.():void 0})).filter(e=>e.slug&&typeof e.chap=="number")}var la=Object.defineProperty,ca=(a,t,e)=>t in a?la(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e,ua=(a,t,e)=>(ca(a,typeof t!="symbol"?t+"":t,e),e);class St extends m{async getRawTitleData(){const t=new URLSearchParams(location.search),e=t.get("episode_no"),r=t.get("title_no");if(e||!r)return;const s=await super.getRawTitleData();if(!s)return;const n=location.pathname.split("/")[1];return{...s,slug:`${s.slug}?title_no=${r}`,id:r,langs:[n].filter(Boolean),chapters:s.chapters.map(i=>({...i,lang:n})),hasMoreChapters:(document.querySelector(".paginate")?.childElementCount??1)>1}}async getRawReaderData(){const t=new URLSearchParams(location.search),e=t.get("episode_no"),r=t.get("title_no");if(!e||!r)return;const s=L(g(".paginate > span:not(:first-child)|text"));if(s===void 0)return;const{chap:n}=s,i=document.title.split("|")[1]?.trim();if(!i)return;const o=location.pathname.split("/"),l=`${o.slice(0,4).join("/")}/list?title_no=${r}`,c=await this.getChapters({sel:"#sequence_scroll li.eg-flick-panel,#toolbar .episode_lst li[data-episode-no]",url:"a|attr:href",label:"|attr:data-episode-no || .num|text"},{lazy:!1,titleId:r,titleSlug:l}),u=o[1];return{chap:n,lang:u,slug:`${location.pathname}?title_no=${r}&episode_no=${e}`,basePath:"",imgs:await this.getReaderImgs(),isWebtoon:!0,title:{id:r,url:l,slug:l,name:i,langs:[u],chapters:(c??[]).map(d=>({...d,lang:u})),hasMoreChapters:!1}}}async getReaderImgs(){const t=_("#_imageList img|[attr:data-url,attr:src]");return t?.length?t:await N(100,50,()=>window.__viewerState__?.scrollViewerParam?.imageList?.map(({url:e})=>e).filter(Boolean))}parseReaderSlug(t,e,r){if(!r)return{basePath:"",slug:e};if(r.startsWith("http://")||r.startsWith("https://")){const s=W(r);return{basePath:"",slug:s.pathname+s.search}}return{basePath:"",slug:r}}}ua(St,"specId","webtoon");var ga=Object.defineProperty,da=(a,t,e)=>t in a?ga(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e,ha=(a,t,e)=>(da(a,typeof t!="symbol"?t+"":t,e),e);class xt extends m{async getRawChaptersData(){const{rawId:t}=this.context;if(!t)return;const e=await pa(t);if(!e)return;const r=document.createElement("DIV");r.innerHTML=e;const s=await this.getChapters({sel:'a[href*="/chapters/"]',url:"|attr:href",label:"span span|text",at:"time|attr:datetime"},{root:r,lazy:!0});if(s)return{chapters:s,hasMore:!1,asc:!1,total:s.length}}}ha(xt,"specId","weebcentral");async function pa(a){const t=`https://weebcentral.com/series/${a}/full-chapter-list`;try{return await(await fetch(t)).text()}catch{return}}const fa=[et,fe,st,q,ot,ut,gt,dt,ht,pt,ft,mt,wt,bt,yt,St,xt];function $t(a){const t=fa.find(e=>e.specId===a.spec.id)??m;return new t(a)}async function ma(a){const{spec:t}=a;if(t){const e=a.siteMeta??t.meta,r=a.type?[a.type]:It(e,t.generic);if(!r.length)return;const s=$t({...a,spec:t,siteMeta:e});return await B(r.map(n=>s.getRawPageByType(n,r.length>1)))}return await B((a.genericSpecs??[]).map(e=>{const r=It(e.meta,e.generic);if(!r.length)return[];const s=$t({...a,spec:e,siteMeta:e.meta});return r.map(n=>s.getRawPageByType(n,!0))}).flat())}function It(a,t){if(location.pathname==="/")return[];const{titleBase:e,readerBase:r}=a,s=location.pathname.split("/").filter(Boolean),n=Mt(s,r),i=Mt(s,e);if(n&&i)return[S.reader,S.title];const o=[];return!i&&(n!==!1||t)&&o.push(S.reader),!n&&(i!==!1||t)&&o.push(S.title),!o.length&&t?[S.reader,S.title]:o}function Mt(a,t){if(!t)return;const e=t.split("/").filter(Boolean),r=e.indexOf("{slug}"),s=r===e.length-1,n=!s&&r!==-1;if(s&&(e.pop(),!e.length))return;const i=a.length-e.length;if(n?i<0:i<=0)return!1;let o=!1;for(let l=0;l<e.length;l++){const c=e[l];if(c[0]!=="{"){if(c!==a[l])return!1;o=!0}}if(o&&i===(n?0:1))return!0}P.PageType=S,P.scrape=ma});
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "trackkun-dom",
3
3
  "author": "endyquang",
4
- "version": "2.0.0",
4
+ "version": "2.0.1",
5
5
  "license": "UNLICENSED",
6
6
  "description": "MP DOM parser & configurations",
7
7
  "main": "index.js",
package/stripper.js CHANGED
@@ -1 +1 @@
1
- (function(s,l){typeof exports=="object"&&typeof module<"u"?l(exports):typeof define=="function"&&define.amd?define(["exports"],l):(s=typeof globalThis<"u"?globalThis:s||self,l(s.$mpStripper={}))})(this,function(s){"use strict";var l=Object.defineProperty,T=(t,e,n)=>e in t?l(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,H=(t,e,n)=>(T(t,typeof e!="symbol"?e+"":e,n),n);class f{constructor(){H(this,"elsPool",new Map)}check(e){if(!e||e===document.body)return!0;const n=this.elsPool.get(e);if(n!==void 0)return n;const r=getComputedStyle(e);if(!(r.display!=="none"&&+(r.opacity??"1")>.1))return this.elsPool.set(e,!1),!1;const o=this.check(e.parentElement);return this.elsPool.set(e,o),o}}function d(t=0){return new Promise(e=>setTimeout(e,t))}async function w(t,e,n){const r=await n(()=>{t=0});if(r!==void 0)return r;if(!(t<=0))return await new Promise(o=>{setTimeout(async()=>{const i=await w(t-1,e,n);o(i)},e)})}async function P(t,e,n=0){const r=e.root??document.documentElement,o=e.timeoutMs??1e4;return w(e.lazy===!0?o/50:0,50,()=>{const i=e.all===!0?Array.from(r.querySelectorAll(t)):r.querySelector(t)??void 0;return(e.all?!i?.length:!i)?void 0:i})}function u(t){const e=t.getBoundingClientRect();return e.width>=200&&e.height>=200}async function L(t,e){const n=await k(t,e);return g(n?.parentElement??t)}async function k(t,e){if(e?.imgDivs)return await P(e.imgDivs,{lazy:!0,timeoutMs:15e3});const n=Array.from(t.querySelectorAll(e?.imgs?.split("|")[0]??"img,canvas"));if(!n.length)return;const r=new f;return n.find(o=>r.check(o)&&(u(o)||o instanceof HTMLImageElement&&(!o.width||!o.height)))}function g(t){return t===document.documentElement||t.scrollHeight-t.clientHeight>=10&&window.getComputedStyle(t).overflow!=="visible"?t:g(t.parentElement)}function C(t){if(t instanceof HTMLOptionElement){const e=t.parentElement instanceof HTMLOptGroupElement?t.parentElement.parentElement:t.parentElement;if(!e||!(e instanceof HTMLSelectElement))return;const n=t.getAttribute("value")||"";if(e.value===n)return;e.value=n,e.dispatchEvent(new Event("change"));return}return t instanceof HTMLAnchorElement&&t.addEventListener("click",e=>e.preventDefault(),{once:!0}),t.click()}async function I(t){const e=await q(t),n=t?.content;return n?await w(e?30:10,100,()=>{for(const r of n.split(",")){const o=document.querySelector(r);if(o)return o}})??document.body:document.body}async function q(t){const{lstrip:e,lstripBtn:n}=t||{};if(!e||!n||document.querySelector(e))return!1;const r=await w(50,30,()=>document.querySelector(n));return r?(C(r),await d(),!0):!1}function R(t){return h(t)}async function h(t,e=!1,n=0){const r=await I(t),o=await L(r,t);await $(o,{restMs:150,durationMs:15e3});const i=new f,c=t?.imgDivs?D(r,t.imgDivs,i):E(r,i),a=c===void 0;if(a&&n===10){if(!t?.imgDivs&&v(r,i))return r;throw new Error("EMPTY")}return c!==!1?(await d(500),await h(t,!1,a?n+1:0),r):e?r:await h(t,!0)}function D(t,e,n){const r=Array.from(t.querySelectorAll(e));if(r.length)return r.some(o=>v(o,n)?!1:E(o,n)!==!1)}function E(t,e){const n=Array.from(t.querySelectorAll("img"));let r=!1;for(const o of n){if(!e.check(o))continue;const i=u(o);if(r=r||i,o.complete){if(i&&!o.naturalWidth&&!o.naturalHeight)throw new Error("IMG_ERR")}else if(i||!o.width||!o.height)return!0}return r?!1:void 0}function v(t,e){return Array.from(t.querySelectorAll("canvas")).some(n=>e.check(n)&&u(n))}async function $(t,{restMs:e,durationMs:n}){await j(t,n,e),t.scrollTop=0,await d(e)}async function j(t,e,n){t.style.setProperty("scroll-behavior","auto");let r=e;for(;r>0&&t.scrollTop+t.clientHeight+200<t.scrollHeight;){const o=t.scrollHeight-t.scrollTop-t.clientHeight;t.scrollTop+=o/(r/n),r-=n,await d(n)}}async function U(t,e){const n=e?.imgDivs;return n?await W(t,n):await x(t,e)}async function W(t,e){const n=Array.from(t.querySelectorAll(e)),r=[],o=new f;for(const i of n){const c=Array.from(i.querySelectorAll("img,canvas"));for(const a of c)o.check(a)&&u(a)&&r.push(a)}return r}function x(t,e){const n=[],r={},o=new f;return t.querySelectorAll(e?.imgs?.split("|")[0]??"img,canvas").forEach(async i=>{if(!(!o.check(i)&&u(i))){if(i instanceof HTMLImageElement){const c=r[i.src];if(c!==void 0&&c!==-1){n.splice(c,1);return}r[i.src]=n.length}n.push(i)}}),n}async function O(t){return t instanceof HTMLCanvasElement?t.toDataURL("image/jpeg",1):await z(t)}async function z(t){if(!t.src.startsWith("blob:")||await G(t))return t.src;const e=document.createElement("canvas"),n=e.getContext("2d"),r=t.naturalWidth,o=t.naturalHeight;return e.width=r,e.height=o,n?.drawImage(t,0,0,r,o),e.toDataURL("image/jpeg",1)}function G(t){return new Promise(e=>{const n=new Image;n.onload=()=>e(!0),n.onerror=()=>e(!1),n.src=t.src})}async function B({title:t,imgs:e}){const n=navigator.userAgent.toLowerCase().includes("android"),r=await Promise.all(e.map(async({src:a,el:A})=>{let m,y;const S=a.startsWith("data:");if(n){const M=a.startsWith("blob:");!M&&!S&&(y=await p(a,A)),m=M?await F(a):a}else S?(m=await _(a),y=await p(m)):(m=a,y=await p(a,A));return{src:m,el:y}}));document.open(),document.close(),document.documentElement.style.setProperty("background","black"),document.title=t;const o=document.createElement("meta");o.setAttribute("name","viewport"),o.setAttribute("content","width=device-width, initial-scale=1, user-scalable=0"),document.head.appendChild(o);const i=document.createElement("div");i.style.setProperty("display","none");const c=document.createElement("code");c.innerText=r.map(({src:a})=>a).join(" "),i.appendChild(c),document.body.appendChild(i),r.forEach(({el:a})=>a&&document.body.appendChild(a))}function p(t,e){if(e&&e instanceof HTMLImageElement)return Array.from(e.attributes).forEach(r=>{r.name!=="src"&&e.removeAttribute(r.name)}),e;const n=(r=1)=>new Promise((o,i)=>{const c=document.createElement("img");c.onload=()=>o(c),c.onerror=()=>{r<2?n(r+1).then(o).catch(i):i(new Error("IMG_ERR"))},c.src=t});return n()}async function _(t){const e=await(await fetch(t)).blob();return URL.createObjectURL(e)}async function F(t){const e=await fetch(t);return await Q(await e.blob())}function Q(t){return new Promise((e,n)=>{const r=new FileReader;r.onloadend=()=>e(r.result),r.readAsDataURL(t),r.onerror=n})}async function V({spec:t,raw:e}){const n=await b({spec:t,raw:e});return await B({title:e.title.name,imgs:n}),{...e,prev:void 0,imgs:void 0,title:{...e.title,chapters:[]}}}async function b({spec:t,raw:e}){const n=e.imgs?.length?e.imgs.map(r=>({src:r})):await Y(t.reader);if(!n.length)throw new Error("Empty");return n}async function Y(t){const e=await R(t),n=await U(e,t);return await Promise.all(n.map(async r=>({src:await O(r),el:r})))}s.loadImages=b,s.strip=V});
1
+ (function(s,l){typeof exports=="object"&&typeof module<"u"?l(exports):typeof define=="function"&&define.amd?define(["exports"],l):(s=typeof globalThis<"u"?globalThis:s||self,l(s.$mpStripper={}))})(this,function(s){"use strict";var l=Object.defineProperty,b=(t,e,n)=>e in t?l(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,A=(t,e,n)=>(b(t,typeof e!="symbol"?e+"":e,n),n);class m{constructor(){A(this,"elsPool",new Map)}check(e){if(!e||e===document.body)return!0;const n=this.elsPool.get(e);if(n!==void 0)return n;const r=getComputedStyle(e);if(!(r.display!=="none"&&+(r.opacity??"1")>.1))return this.elsPool.set(e,!1),!1;const o=this.check(e.parentElement);return this.elsPool.set(e,o),o}}function p(t=0){return new Promise(e=>setTimeout(e,t))}async function f(t,e,n){const r=await n(()=>{t=0});if(r!==void 0)return r;if(!(t<=0))return await new Promise(o=>{setTimeout(async()=>{const i=await f(t-1,e,n);o(i)},e)})}async function S(t,e,n=0){const r=e.root??document.documentElement,o=e.timeoutMs??1e4;return f(e.lazy===!0?o/50:0,50,()=>{const i=e.all===!0?Array.from(r.querySelectorAll(t)):r.querySelector(t)??void 0;return(e.all?!i?.length:!i)?void 0:i})}function u(t){const e=t.getBoundingClientRect();return e.width>=200&&e.height>=200}async function M(t,e){const n=await P(t,e);return y(n?.parentElement??t)}async function P(t,e){if(e?.imgDivs)return await S(e.imgDivs,{lazy:!0,timeoutMs:15e3});const n=Array.from(t.querySelectorAll(e?.imgs?.split("|")[0]??"img,canvas"));if(!n.length)return;const r=new m;return n.find(o=>r.check(o)&&(u(o)||o instanceof HTMLImageElement&&(!o.width||!o.height)))}function y(t){return t===document.documentElement||t.scrollHeight-t.clientHeight>=10&&window.getComputedStyle(t).overflow!=="visible"?t:y(t.parentElement)}function T(t){if(t instanceof HTMLOptionElement){const e=t.parentElement instanceof HTMLOptGroupElement?t.parentElement.parentElement:t.parentElement;if(!e||!(e instanceof HTMLSelectElement))return;const n=t.getAttribute("value")||"";if(e.value===n)return;e.value=n,e.dispatchEvent(new Event("change"));return}return t instanceof HTMLAnchorElement&&t.addEventListener("click",e=>e.preventDefault(),{once:!0}),t.click()}async function q(t){const e=await L(t),n=t?.content;return n?await f(e?30:10,100,()=>{for(const r of n.split(",")){const o=document.querySelector(r);if(o)return o}})??document.body:document.body}async function L(t){const{lstrip:e,lstripBtn:n}=t||{};if(!e||!n||document.querySelector(e))return!1;const r=await f(50,30,()=>document.querySelector(n));return r?(T(r),await p(),!0):!1}function k(t){return d(t)}async function d(t,e=0,n=0){const r=await q(t);H(r);const o=await M(r,t);await C(o,{stepMs:100,durationMs:1e4});const i=new m,c=t?.imgDivs?$(r,t.imgDivs,i):g(r,i),a=c===void 0;if(a&&n===10){if(!t?.imgDivs&&v(r,i))return r;throw new Error("EMPTY")}return c!==!1?(await p(500),await d(t,0,a?n+1:0),r):e>=1?r:await d(t,e+1)}function H(t){const e=Array.from(t.querySelectorAll('img[loading="lazy"]'));for(const n of e)n.setAttribute("loading","eager");h(t,"data-src"),h(t,"data-url")}function h(t,e){const n=Array.from(t.querySelectorAll(`img[${e}]`));for(const r of n){const o=r.getAttribute(e)?.split(" ")[0];o&&r.src!==o&&(r.src=o)}}function $(t,e,n){const r=Array.from(t.querySelectorAll(e));if(r.length)return r.some(o=>v(o,n)?!1:g(o,n)!==!1)}function g(t,e){const n=Array.from(t.querySelectorAll("img"));let r=!1;for(const o of n){if(!e.check(o))continue;const i=u(o);if(r=r||i,o.complete){if(i&&!o.naturalWidth&&!o.naturalHeight)throw new Error("IMG_ERR")}else if(i||!o.width||!o.height)return!0}return r?!1:void 0}function v(t,e){return Array.from(t.querySelectorAll("canvas")).some(n=>e.check(n)&&u(n))}async function C(t,{stepMs:e,durationMs:n}){await I(t,n,e)}async function I(t,e,n){t.style.setProperty("scroll-behavior","auto"),await new Promise(r=>{const o=t.scrollTop,i=t.scrollHeight-t.scrollTop-o,c=performance.now();function a(){const Y=performance.now()-c,E=Math.min(Y/e,1);E<1?(t.scrollTop=o+i*E,setTimeout(()=>requestAnimationFrame(a),n)):r()}requestAnimationFrame(a)})}async function R(t,e){const n=e?.imgDivs;return n?await D(t,n):await j(t,e)}async function D(t,e){const n=Array.from(t.querySelectorAll(e)),r=[],o=new m;for(const i of n){const c=Array.from(i.querySelectorAll("img,canvas"));for(const a of c)o.check(a)&&u(a)&&r.push(a)}return r}function j(t,e){const n=[],r={},o=new m;return t.querySelectorAll(e?.imgs?.split("|")[0]??"img,canvas").forEach(async i=>{if(!(!o.check(i)&&u(i))){if(i instanceof HTMLImageElement){const c=r[i.src];if(c!==void 0&&c!==-1){n.splice(c,1);return}r[i.src]=n.length}n.push(i)}}),n}async function x(t){return t instanceof HTMLCanvasElement?t.toDataURL("image/jpeg",1):await U(t)}async function U(t){if(!t.src.startsWith("blob:")||await W(t))return t.src;const e=document.createElement("canvas"),n=e.getContext("2d"),r=t.naturalWidth,o=t.naturalHeight;return e.width=r,e.height=o,n?.drawImage(t,0,0,r,o),e.toDataURL("image/jpeg",1)}function W(t){return new Promise(e=>{const n=new Image;n.onload=()=>e(!0),n.onerror=()=>e(!1),n.src=t.src})}function z(t){const e=/iPad|iPhone|iPod/.test(navigator.userAgent);return Promise.all(t.map(async({src:n,el:r})=>{let o,i;const c=n.startsWith("data:");if(e)c?(o=await O(n),i=await w(o)):(o=n,i=await w(n,r));else{const a=n.startsWith("blob:");!a&&!c&&(i=await w(n,r)),o=a?await F(n):n}return{src:o,el:i}}))}function w(t,e){if(e&&e instanceof HTMLImageElement)return Array.from(e.attributes).forEach(r=>{r.name!=="src"&&e.removeAttribute(r.name)}),e;const n=(r=1)=>new Promise((o,i)=>{const c=document.createElement("img");c.onload=()=>o(c),c.onerror=()=>{r<2?n(r+1).then(o).catch(i):i(new Error("IMG_ERR"))},c.src=t});return n()}async function O(t){const e=await(await fetch(t)).blob();return URL.createObjectURL(e)}async function F(t){const e=await fetch(t);return await G(await e.blob())}function G(t){return new Promise((e,n)=>{const r=new FileReader;r.onloadend=()=>e(r.result),r.readAsDataURL(t),r.onerror=n})}async function B({title:t,imgs:e}){document.open(),document.close(),document.documentElement.style.setProperty("background","black"),document.title=t;const n=document.createElement("meta");n.setAttribute("name","viewport"),n.setAttribute("content","width=device-width, initial-scale=1, user-scalable=0"),document.head.appendChild(n);const r=document.createElement("div");r.style.setProperty("display","none");const o=document.createElement("code");o.innerText=e.map(({src:i})=>i).join(" "),r.appendChild(o),document.body.appendChild(r),e.forEach(({el:i})=>i&&document.body.appendChild(i))}async function _({spec:t,raw:e}){const n=await Q({spec:t,raw:e});return await B({title:e.title.name,imgs:n}),{...e,prev:void 0,imgs:void 0,title:{...e.title,chapters:[]}}}async function Q({spec:t,raw:e}){const n=e.imgs?.length?e.imgs.map(r=>({src:r})):await V(t.reader);if(!n.length)throw new Error("Empty");return await z(n)}async function V(t){const e=await k(t),n=await R(e,t);return await Promise.all(n.map(async r=>({src:await x(r),el:r})))}s.strip=_});