trackkun-dom 1.11.1 → 1.11.2

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 (2) hide show
  1. package/index.js +1 -1
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -1 +1 @@
1
- (function(B,N){typeof exports=="object"&&typeof module<"u"?N(exports):typeof define=="function"&&define.amd?define(["exports"],N):(B=typeof globalThis<"u"?globalThis:B||self,N(B._trackkun_={}))})(this,function(B){"use strict";function N(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 S(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 O(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 O(a-1,e,t);s(n)},e)})}async function x(a,e,t=0){const r=e.root??document.documentElement,s=e.timeoutMs??1e4;return O(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})}async function Q(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})}const Y={text:_e,attr:ze,"attr-contain":Ae,value:ke,row:We,"bg-image":Ee};function g(a,e){if(a)return G(a,e,je)}function _(a,e){if(a)return G(a,e,Le)}function G(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=Oe(s);if(!n)continue;const i=t(e??document.documentElement,n.selector,n.instructions);if(i)return i}}function Oe(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 je(a,e,t){if(!e)return Z(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=Z(i,t);if(o)return o}}}function Le(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=Y[i.extractor],l=o(n,i.param);if(l){s.push(l);break}}if(s.length)return s}function Z(a,e){for(const t of e){const r=Y[t.extractor],s=r(a,t.param);if(s)return s}}function _e(a){return Array.from(a.childNodes).filter(e=>e.nodeType===3).map(e=>j(e.textContent)).filter(Boolean).join(" ").trim()||j(a.textContent)}function ze(a,e){return j(a.getAttribute(e))}function Ae(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 ke(a){return a.value}function We(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 Ee(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 Ue=(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))(Ue||{}),qe=(a=>(a[a.ok=1]="ok",a[a.hidden=2]="hidden",a[a.deleted=3]="deleted",a))(qe||{}),Fe=(a=>(a[a.aggregator=0]="aggregator",a[a.scanlator=1]="scanlator",a))(Fe||{}),Ve=(a=>(a[a.pending=0]="pending",a[a.completed=1]="completed",a[a.offline=2]="offline",a[a.incompat=3]="incompat",a))(Ve||{}),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 He=/(vol(ume)?|season)(\s*|-|\.)(\d+)/i,Je=/^S([1-9])\s/i,Qe=/(ch(ap(t(er)?|\.)?|\.)?|^#|episode\.?|capitolo\.?|capitulo\.?|bölüm\.?)(\s*|-)(\d+([_-~,.]\d+)?)/i,Ye=/\d+([_-~,.]\d+)?/,Ge=/[_-~,]/;function Ze(a){const e=a.match(He);if(e)return{volStr:e[0],volValueStr:e[4]};const t=a.match(Je);return t?{volStr:t[0],volValueStr:t[1]}:{}}function P(a){if(!a)return;if(!isNaN(+a))return{chap:+a};const{volStr:e,volValueStr:t}=Ze(a),r=e?a.replace(e,"").trim():a,s=r.match(Qe),n=r.match(Ye),i=s?.[6],o=i??n?.[0];if(!o)return;const l=+o.replace(Ge,".");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}}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),Ke(a)}function Ke(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 Xe=[{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:"ann",it:"anno",es:"a\xF1o"}}];function K(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=Xe.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=X(i)??X(i,["a","an"]);if(!o)return;const l=r-o*n.seconds*1e3;return l>0?l:void 0}function X(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 ee(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 te(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 et(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 d=10-r.length;if(d>0){const w=l+d<=a.length?a.slice(l,l+d):t.slice(0,d);r.push(...w)}break}const c=a[l],u=c.id!==void 0,p=t.findIndex(d=>u&&d.id===c.id||d.slug===c.slug||d.name==c.name),h=p===-1?void 0:t.splice(p,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 tt(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 $=(a=>(a.title="title",a.reader="reader",a.releases="releases",a.chapters="chapters",a.search="search",a))($||{}),at=Object.defineProperty,rt=(a,e,t)=>e in a?at(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,D=(a,e,t)=>(rt(a,typeof e!="symbol"?e+"":e,t),t);class k{constructor(e){D(this,"siteId"),D(this,"spec"),D(this,"siteMeta"),D(this,"tags"),D(this,"context"),D(this,"methodsMap",{[$.title]:()=>this.getRawTitleData(),[$.reader]:()=>this.getRawReaderData(),[$.releases]:()=>this.getRawReleasesData(),[$.search]:()=>this.getRawSearchData(),[$.chapters]:()=>this.getRawChaptersData()}),D(this,"normalizedTagsMap"),this.siteId=e.siteId,this.spec=e.spec,this.siteMeta=e.siteMeta,this.tags=e.tags,this.context=e.context}async getRawSearchData(){throw new Error("Unimplemented")}async getRawPageByType(e,t=!1){const r=await this.methodsMap[e](),s=!r&&(e===$.title||e===$.reader)&&await nt(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}")],p=e.replace("{lang}",l).replace("{titleId}",c).replace("{titleSlug}",u);if(n.startsWith(p))return{basePath:p,lang:l.toLowerCase(),titleId:c,titleSlug:u,slug:n.replace(p,"")}}}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=S(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=tt(e.rawReleases,t);if(r.length)return this.context?.oldRawReleases?et(r,this.context.oldRawReleases):{rawReleases:r,hasMore:!0}}getTagIdsFromNames(e){if(!e?.length)return;const t=this.normalizedTagsMap??(this.normalizedTagsMap=st(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)}}D(k,"specId"),D(k,"siteId");function st(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 nt(a){return it()===404||a[404]&&await x(a[404],{lazy:!0,timeoutMs:5e3})?!0:document.title.toLowerCase().includes("not found")}function it(){try{return window.performance.getEntries().find(a=>a.entryType==="navigation")?.responseStatus}catch{return}}class f extends k{async getRawReleasesData(){if(!this.spec?.releases?.title)return;const{chapter:e,...t}=this.spec.releases.title,r=await x(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=S(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:K(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,...p}=i,{id:h,slug:d}=this.parseTitleSlug(o);if(!d)return;const w=p.id||h,y=await this.getChapters(e,{root:l,titleId:w,titleSlug:d})??[];y.length&&n.push({slug:d,chapters:c||u?y.map(b=>({...b,elIndex:void 0,lang:b.lang??c,ts:b.ts??u})):y,...p,id:w})})),this.finalizeRawReleasesData({rawReleases:n})}getRawTitleData(){return this.getTitleData(this.spec.title)}async getTitleData(e){if(!e||(e.sel||e.lazy)&&!await x(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;let n=_(e.tags)??[];n.length===1&&(n=n[0].split(",").map(h=>h.trim()).filter(Boolean));const 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,p=u&&this.context?.includeImgBytes?await Q(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:p,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 O(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=ee(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 f.isReaderPage(e.reader))return;const r=e.reader.content;if(!(!r||await f.verifyImgsCotainer(r)))return;const s=this.getRawReaderTitleData();if(!s)return;const{id:n,slug:i}=s,o=!!this.context?.disableLazyChapters,l=!!this.context?.includeHiddenChapters,c=await this.getChapters(e.reader?.chapter,{titleId:n,titleSlug:i,lazy:l||!o,includeHiddenChapters:l,timeoutMs:l?3e3:12e4,includeIndex:!0})??[],u=g(e.reader.label)?.toLowerCase().replace(s.name.toLowerCase(),"");if(!u)return;const{vol:p,chap:h=0}=P(u)||{},{slug:d,basePath:w,lang:y,titleId:b}=this.parseReaderSlug(te(t.readerBase,{titleId:n,titleSlug:i}),location.pathname,location.href),v=e.reader?.chapter,m=this.findNeighborChapter({sel:e.reader.prev,basePath:w}),C=this.findNeighborChapter({sel:e.reader.next,basePath:w});return this.finalizeRawReaderData({vol:p,chap:h,lang:y??g(e.reader.lang)?.toLowerCase()??(e.reader.lang?this.siteMeta.defaultLang:void 0),slug:d,basePath:w,imgs:r?void 0:_(e.reader.imgs),title:{id:n||b||g(this.spec.reader?.title.id),url:s.url,slug:i,name:s.name,langs:y?[y]:void 0,img:s.img,chapters:c,hasMoreChapters:!!(v&&c.length&&(v.trigger||m||C))}},{prevSlug:m,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 i=this.context?.lang,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=S(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=[],p=await x(e.sel,{root:t,all:!0,lazy:i,timeoutMs:o});if(!p?.length)return c?.click(),[];const h=(p??[]).map((v,m)=>({id:g(e.id,v),label:g(e.label,v),url:g(e.url,v),at:g(e.at,v),elIndex:m}));c?.click();const d=h.map(({label:v})=>P(v)),w=d[1]?.chap;!d[0]&&(w===void 0||w<=1)&&(d[0]={chap:0});const{readerBase:y}=this.siteMeta,b=te(y,{titleId:r,titleSlug:s});return d.forEach((v,m)=>{if(!v)return;const{id:C,url:T,at:V,elIndex:H}=h[m],R={...v,id:C,ts:K(V,this.siteMeta.defaultLang)};l&&(R.elIndex=H);const Be=T?.startsWith("http")&&!T.includes(`//${location.hostname}/`),J=Be?T:S(T);if(!J){u.push(R);return}if(Be){u.push({...R,slug:J});return}const{slug:Ia,lang:Ca}=this.parseReaderSlug(b,J,T);u.push({...R,slug:Ia,lang:Ca})}),z(u)}static async isReaderPage(e){return!!e.sel&&!!await x(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 x(t,{lazy:!0,all:!1})}findNeighborChapter({sel:e,basePath:t}){const r=g(e);if(!r||r.startsWith("#")||r.startsWith("/#"))return;const s=S(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=P(t),u=P(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 ot=Object.defineProperty,lt=(a,e,t)=>e in a?ot(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,ct=(a,e,t)=>(lt(a,typeof e!="symbol"?e+"":e,t),t);class ae extends f{parseTitleSlug(e){return{slug:S(e)?.split("/").filter(Boolean)[1]}}}ct(ae,"specId","bato");function ut(){return Math.random().toString(16).slice(2)}async function gt({addListener:a,removeListener:e,transform:t,filter:r,handler:s,onTimeout:n,timeout:i,once:o}){return new Promise(l=>{a(p);const c=()=>o===!0&&e(p),u=i?setTimeout(()=>{c(),l(void 0),n?.()},i):void 0;async function p(h,...d){h=t?t(h):h,h!==void 0&&(!r||r(h,...d))&&(c(),l(h),s?.(h,...d),u&&clearTimeout(u))}})}async function pt(a){return(await gt({addListener:e=>window.addEventListener("message",e),removeListener:e=>window.removeEventListener("message",e),...a}))?.data}async function ht(a){const{receiverWindow:e,timeout:t,targetOrigin:r,event:s,args:n}=a,i={reqId:ut(),event:s,args:n};return(e||window)?.postMessage(i,r??"*"),(await pt({filter:o=>o?.data?.resId===i.reqId,timeout:t??3e4,once:!0}))?.result}const L={isAny:!0};function M(a,...e){return ht({event:"tk:fetchResult",args:{baseUrl:a,segments:e}})}var dt=Object.defineProperty,ft=(a,e,t)=>e in a?dt(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,mt=(a,e,t)=>(ft(a,typeof e!="symbol"?e+"":e,t),t);const re=class Ne extends f{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 M(`https://api.${location.host}`,"comic",L,"chapters");if(!t)return e;const r=t.url.split("/").filter(Boolean).slice(-2)[0],s=se(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??ee(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:Ne.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=se(await n.json());return i?{...i,lang:t,asc:!1}:void 0}catch{return}}};mt(re,"specId","comick");let wt=re;function se(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 vt=Object.defineProperty,yt=(a,e,t)=>e in a?vt(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,bt=(a,e,t)=>(yt(a,typeof e!="symbol"?e+"":e,t),t);class ne extends f{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(Rt).filter(Boolean)}}}bt(ne,"specId","lua");function Rt(a){if(!a||typeof a.chapter_name!="string")return;const e=P(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 ie(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 $t=Object.defineProperty,St=(a,e,t)=>e in a?$t(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,xt=(a,e,t)=>(St(a,typeof e!="symbol"?e+"":e,t),t);class q extends f{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=oe(this.spec.reader?.title);if(!e)return;const t=this.finalizeNewSiteMeta(this.siteMeta,{titleBase:this.extractBasePath(S(e))});this.siteMeta=t??this.siteMeta;const r=await super.getRawReaderData();if(r)return{...r,siteMeta:t}}async getRawSearchData(){const e=oe(this.spec.search?.title);if(!e)return;const t=this.finalizeNewSiteMeta(this.siteMeta,{titleBase:this.extractBasePath(S(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=S(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 ie(e,"/").split("/").slice(0,-1).join("/")}}xt(q,"specId","madara");function oe(a){if(!a)return;const e=a.sel?document.querySelector(a.sel)??void 0:void 0;return g(a.url,e)}var Dt=Object.defineProperty,Mt=(a,e,t)=>e in a?Dt(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,It=(a,e,t)=>(Mt(a,typeof e!="symbol"?e+"":e,t),t);class le extends f{async getRawReleasesData(){const e=await this.getVM();if(!e)return super.getRawReleasesData();const t=e.LatestJSON.slice(0,100).map(r=>{const s=r.IndexName;return{slug:s,name:r.SeriesName,chapters:[F(r,s)]}});return this.finalizeRawReleasesData({rawReleases:t})}parseTitleSlug(e){const{slug:t}=super.parseTitleSlug(e);return!t||t.includes("{")?{}:{slug:t}}async getRawTitleData(){const e=await super.getRawTitleData();return e&&{...e,chapters:ce(await this.getVM(),e.slug),hasMoreChapters:!1}}parseReaderSlug(e,t){const{slug:r,basePath:s}=super.parseReaderSlug(e,t);return{slug:r.replace(/-page-\d{1,3}\.html\/?$/,".html"),basePath:s}}async getRawReaderData(){const e=await this.getVM();if(!e)return;const t=document.querySelector(".ImageGallery img.img-fluid")?.getAttribute("ng-src"),r=e.IndexName,s=F(e.CurChapter,r);return this.finalizeRawReaderData({chap:s.chap,slug:s.slug,imgs:Tt(e,t??void 0),basePath:"/"+this.siteMeta.readerBase.replace("{titleSlug}",r)+"/",title:{name:e.SeriesName,slug:r,url:`/${this.siteMeta.titleBase}/${r}`,chapters:ce(e,r),hasMoreChapters:!1}})}getVM(){return O(50,100,()=>window.angular?.element?.(document.documentElement)?.scope()?.vm)}}It(le,"specId","manga4life");function ce(a,e){return(a?.Chapters??a?.CHAPTERS??[]).sort((t,r)=>r.Chapter-t.Chapter).map(t=>F(t,e))}function F(a,e){const t=+a.Chapter[0],r=+a.Chapter.substring(1)/10;return{slug:`${e}-chapter-${r}${t&&t>1?`-index-${t}`:""}.html`,chap:r,ts:Ct(a.Date)}}function Ct(a){const e=new Date(a).valueOf();return e===e?e:void 0}function Tt(a,e){let t=e?.split(".").slice(-1)[0]??"png";t=t.length>=3&&t.length<=4?t:"png";try{const r=a.CurChapter.Chapter.slice(1,-1),s=a.CurChapter.Chapter[a.CurChapter.Chapter.length-1],n=s!=="0"?`${r}.${s}`:r,i=`https://${a.CurPathName}/manga/${a.IndexName}/${a.CurChapter.Directory?`${a.CurChapter.Directory}/`:""}${n}-`;return a.Pages.map(o=>{const l=(o+"").padStart(3,"0");return`${i}${l}.${t}`})}catch{return}}var Pt=Object.defineProperty,Bt=(a,e,t)=>e in a?Pt(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,Nt=(a,e,t)=>(Bt(a,typeof e!="symbol"?e+"":e,t),t);const Ot={a:.1,b:.2,c:.3,d:.4};class ue extends k{parseTitleSlug(e){return{slug:S(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:p})=>p==="manga"),o=I(s.volume),l=I(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([M(e,L),M(e,L,"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:p,title:h,volume:d,chapter:w,translatedLanguage:y}=c;return{slug:p||u,label:h||void 0,vol:I(d),chap:I(w),lang:y||"en",ts:new Date(c.readableAt).valueOf()}}).filter(l=>l?.chap!=null)??[],{data:n}=t.value;if(!n)return;const i=pe({data:n,getTagIdsFromNames:l=>this.getTagIdsFromNames(l)});if(!i)return;const o=this.context?.includeImgBytes&&i.img?await Q(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([M(e,"chapter",L),M(e,"at-home","server",L),M(e,"manga",L,"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:p,dataSaver:h,hash:d}}=r.value,w=n.relationships?.find?.(R=>R.type==="manga");if(!w)return;const y=pe({data:w,getTagIdsFromNames:R=>this.getTagIdsFromNames(R)});if(!y||typeof s.value.volumes!="object")return;const b=ge(s.value)??[];(typeof o!="string"||o==="none")&&!b.length&&b.push({chap:0,slug:n.id});const v=b.findIndex(R=>R.slug===n.id),m=n.relationships?.find?.(R=>R.type==="scanlation_group"),C=u.endsWith("/")?u:u+"/",T=!!localStorage.getItem("md")?.includes?.('"dataSaver":true'),V=`${C}${T?"data-saver":"data"}/`,H=((T?h:p)??[]).map?.(R=>`${V}${d}/${R}`)??[];return{externalUrl:l,vol:I(i),inferVol:b[v]?.inferVol,chap:I(o)||0,imgs:H,lang:c,slug:n.id,prev:b[v+1],next:b[v-1],basePath:"/chapter/",groupName:m?.attributes?.name,groupUrl:m?.attributes?.website,isWebtoon:w?.attributes?.tags?.some(R=>R.attributes.name.en==="Long Strip"),title:{...y,chapters:b}}}async getRawChaptersData(){if(!this.context)return;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=ge(await s.json())}catch{return}if(r)return{chapters:r,lang:t,asc:!1,hasMore:!1,total:r.length}}}Nt(ue,"specId","mangadex");function I(a){if(typeof a!="string"||a==="none")return;const e=parseFloat(a);if(e!==e)return;const t=a[a.length-1];return e+(Ot[t]??0)}function ge(a){if(typeof a.volumes!="object")return;const e=Object.values(a.volumes).map(({volume:t,chapters:r})=>{const s=I(t);return Object.values(r).map(({id:n,chapter:i})=>{const o=I(i);if(o!==void 0)return{vol:s,chap:o,slug:n}})}).flat().filter(Boolean).reverse();return z(e)}function pe({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 p=jt(),h=(i??[])?.map?.(m=>typeof m=="string"?m:void 0).filter(Boolean)??[],d=h.filter(m=>m&&(!p||p.includes(m))),w=o?.map?.(m=>{const[[,C]=[]]=Object.entries(m);return C}),y=s?.find?.(m=>m.type==="cover_art")?.attributes?.fileName,b=y?`https://mangadex.org/covers/${t}/${y}.256.jpg`:void 0,v=(l||[]).map(m=>m?.attributes?.name?.en).concat(c).filter(Boolean);return{url:`${location.origin}/title/${t}`,slug:t,name:u,altNames:w,langs:d.length>0?d:h.length>0?h:["en"],img:b,tags:e(v)}}function jt(){const a=localStorage.getItem("md");if(a)try{const e=JSON.parse(a)?.userPreferences?.filteredLanguages;return e?.length?e:void 0}catch{return}}var Lt=Object.defineProperty,_t=(a,e,t)=>e in a?Lt(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,zt=(a,e,t)=>(_t(a,typeof e!="symbol"?e+"":e,t),t);class he extends f{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 x(".current-viewtype",{lazy:!0,all:!1}))?.textContent?.trim().toLowerCase()!=="volume")return await super.getRawReaderData()}async getRawChaptersData(){const e=this.context?.lang;if(!e)return;const t=await x(`.tab-content[data-name="chapter"] a.dropdown-item[data-code="${e.toUpperCase()}"]`,{lazy:!0,all:!1});if(t)return t.click(),await x(`.tab-content[data-name="chapter"] li.item[data-number] a[href*="/${e}/"]`,{lazy:!0,all:!1}),await super.getRawChaptersData()}}zt(he,"specId","mangafire");var At=Object.defineProperty,kt=(a,e,t)=>e in a?At(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,Wt=(a,e,t)=>(kt(a,typeof e!="symbol"?e+"":e,t),t);class de extends f{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 O(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(",")}}Wt(de,"specId","mangago");var Et=Object.defineProperty,Ut=(a,e,t)=>e in a?Et(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,qt=(a,e,t)=>(Ut(a,typeof e!="symbol"?e+"":e,t),t);class fe extends f{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]}))}}}qt(fe,"specId","mangaplus");var Ft=Object.defineProperty,Vt=(a,e,t)=>e in a?Ft(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,Ht=(a,e,t)=>(Vt(a,typeof e!="symbol"?e+"":e,t),t);class me extends f{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}))}}}Ht(me,"specId","mangareader");var Jt=Object.defineProperty,Qt=(a,e,t)=>e in a?Jt(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,Yt=(a,e,t)=>(Qt(a,typeof e!="symbol"?e+"":e,t),t);class we 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:ie(location.pathname,"/")},s=e.title,n=document.querySelector(s.sel)??void 0;if(!n)return;const i=S(g(s.url,n));if(i===void 0)return;const o=n.querySelector(s.chapter.sel)??void 0;if(!(!o||S(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}}Yt(we,"specId","mangastream");var Gt=Object.defineProperty,Zt=(a,e,t)=>e in a?Gt(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,Kt=(a,e,t)=>(Zt(a,typeof e!="symbol"?e+"":e,t),t);class ve extends f{async getRawReaderData(){const e=await super.getRawReaderData();if(e)return{...e,title:{...e.title,name:e.title.name.replace("Ritorna a","").trim()}}}}Kt(ve,"specId","mangaworld");var Xt=Object.defineProperty,ea=(a,e,t)=>e in a?Xt(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,ta=(a,e,t)=>(ea(a,typeof e!="symbol"?e+"":e,t),t);class ye extends f{async getRawTitleData(){const e=await super.getRawTitleData();if(e)return{...e,hasMoreChapters:e.chapters.length===50}}}ta(ye,"specId","mgeko");var aa=Object.defineProperty,ra=(a,e,t)=>e in a?aa(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,sa=(a,e,t)=>(ra(a,typeof e!="symbol"?e+"":e,t),t);class be extends f{async getRawTitleData(){const e=await super.getRawTitleData();if(!e)return e;const t=await M(`https://api.${location.host}`,"chapter","query");if(!t)return;let r;try{r=new URL(t.url).searchParams.get("series_id")}catch{return}if(!r)return;const{first_page:s,last_page:n}=t.value.meta||{};return{...e,id:r,hasMoreChapters:s!==n}}async getRawChaptersData(){if(!this.context?.rawId)return;const{rawId:e}=this.context;try{const t=await(await fetch(`https://api.${location.host}/chapter/query?page=1&perPage=1000&query=&order=desc&series_id=${e}`)).json();if(!t?.data?.map)return;const r=[];return t.data.forEach(s=>{const{chapter_name:n,chapter_slug:i,created_at:o}=s;if(typeof n!="string"||typeof i!="string")return;const l=P(n);if(l?.chap)return{...l,slug:i,ts:o&&new Date(o).valueOf()||void 0}}),{chapters:r,hasMore:!1,asc:!1}}catch{return}}}sa(be,"specId","reaper");var na=Object.defineProperty,ia=(a,e,t)=>e in a?na(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,oa=(a,e,t)=>(ia(a,typeof e!="symbol"?e+"":e,t),t);class Re extends f{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 $e({...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:{...$e({...e.title,url:t,tags:[]},".episode-list .js-ep-cnt"),hasMoreChapters:!1}}}async getRawChaptersData(){if(!this.context)return;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 la(await n.json())}catch{return}}parseTitleSlug(e){if(!e)return{};const t=e.split("/").filter(Boolean);return{slug:t[1]??t[0]}}}oa(Re,"specId","tapas");function $e(a,e){const t=ca(e)>20;return{...a,chapters:t?[]:a.chapters,hasMoreChapters:t}}function la(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 ca(a){return+(document.querySelector(a)?.textContent?.trim().split(" ")[0]||0)}var ua=Object.defineProperty,ga=(a,e,t)=>e in a?ua(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,pa=(a,e,t)=>(ga(a,typeof e!="symbol"?e+"":e,t),t);class Se extends f{async getRawReleasesData(){const e=await super.getRawReleasesData();if(e)return{...e,rawReleases:e.rawReleases.map(t=>({...t,id:ha(t.slug)}))}}}pa(Se,"specId","truyenqq");function ha(a){return a.substring(a.lastIndexOf("-")+1).replace(".html","")||void 0}var da=Object.defineProperty,fa=(a,e,t)=>e in a?da(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,ma=(a,e,t)=>(fa(a,typeof e!="symbol"?e+"":e,t),t);class xe extends f{async getRawTitleData(){const e=await super.getRawTitleData();return e?.img?{...e,img:wa(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=M(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 p=De(n.value);return p?{chapters:p,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=De(await c.json());if(u)return{chapters:u,title:e,total:l,skip:0,hasMore:!1}}}ma(xe,"specId","vortex");function wa(a){try{return new URL(a,location.href).searchParams.get("url")||void 0}catch{return}}function De(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 va=Object.defineProperty,ya=(a,e,t)=>e in a?va(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,ba=(a,e,t)=>(ya(a,typeof e!="symbol"?e+"":e,t),t);class Me extends f{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=P(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(p=>({...p,lang:u})),hasMoreChapters:!1}}}async getReaderImgs(){const e=_("#_imageList img|[attr:data-url,attr:src]");return e?.length?e:await O(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}}}ba(Me,"specId","webtoon");var Ra=Object.defineProperty,$a=(a,e,t)=>e in a?Ra(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,Sa=(a,e,t)=>($a(a,typeof e!="symbol"?e+"":e,t),t);class Ie extends f{async getRawChaptersData(){const e=this.context?.rawId;if(!e)return;const t=await xa(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}}}Sa(Ie,"specId","weebcentral");async function xa(a){const e=`https://weebcentral.com/series/${a}/full-chapter-list`;try{return await(await fetch(e)).text()}catch{return}}const Da=[ae,wt,ne,q,le,ue,he,de,fe,me,we,ve,ye,be,Re,xe,Se,Me,Ie];function Ce(a){const e=Da.find(t=>t.specId===a.spec.id)??f;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]:Te(t,e.generic);if(!r.length)return;const s=Ce({...a,spec:e,siteMeta:t});return await N(r.map(n=>s.getRawPageByType(n,r.length>1)))}return await N((a.genericSpecs??[]).map(t=>{const r=Te(t.meta,t.generic);if(!r.length)return[];const s=Ce({...a,spec:t,siteMeta:t.meta});return r.map(n=>s.getRawPageByType(n,!0))}).flat())}function Te(a,e){if(location.pathname==="/")return[];const{titleBase:t,readerBase:r}=a,s=location.pathname.split("/").filter(Boolean),n=Pe(s,r),i=Pe(s,t);if(n&&i)return[$.reader,$.title];const o=[];return!i&&(n!==!1||e)&&o.push($.reader),!n&&(i!==!1||e)&&o.push($.title),!o.length&&e?[$.reader,$.title]:o}function Pe(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}B.PageType=$,B.scrape=Ma});
1
+ (function(B,N){typeof exports=="object"&&typeof module<"u"?N(exports):typeof define=="function"&&define.amd?define(["exports"],N):(B=typeof globalThis<"u"?globalThis:B||self,N(B._trackkun_={}))})(this,function(B){"use strict";function N(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 S(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 O(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 O(a-1,e,t);s(n)},e)})}async function x(a,e,t=0){const r=e.root??document.documentElement,s=e.timeoutMs??1e4;return O(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})}async function Q(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})}const Y={text:_e,attr:ze,"attr-contain":Ae,value:ke,row:We,"bg-image":Ee};function h(a,e){if(a)return G(a,e,je)}function _(a,e){if(a)return G(a,e,Le)}function G(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=Oe(s);if(!n)continue;const i=t(e??document.documentElement,n.selector,n.instructions);if(i)return i}}function Oe(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 je(a,e,t){if(!e)return Z(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=Z(i,t);if(o)return o}}}function Le(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=Y[i.extractor],l=o(n,i.param);if(l){s.push(l);break}}if(s.length)return s}function Z(a,e){for(const t of e){const r=Y[t.extractor],s=r(a,t.param);if(s)return s}}function _e(a){return Array.from(a.childNodes).filter(e=>e.nodeType===3).map(e=>j(e.textContent)).filter(Boolean).join(" ").trim()||j(a.textContent)}function ze(a,e){return j(a.getAttribute(e))}function Ae(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 ke(a){return a.value}function We(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 Ee(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 Ue=(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))(Ue||{}),qe=(a=>(a[a.ok=1]="ok",a[a.hidden=2]="hidden",a[a.deleted=3]="deleted",a))(qe||{}),Ve=(a=>(a[a.aggregator=0]="aggregator",a[a.scanlator=1]="scanlator",a))(Ve||{}),Fe=(a=>(a[a.pending=0]="pending",a[a.completed=1]="completed",a[a.offline=2]="offline",a[a.incompat=3]="incompat",a))(Fe||{}),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 He=/(vol(ume)?|season)(\s*|-|\.)(\d+)/i,Je=/^S([1-9])\s/i,Qe=/(ch(ap(t(er)?|\.)?|\.)?|^#|episode\.?|capitolo\.?|capitulo\.?|bölüm\.?)(\s*|-)(\d+([_-~,.]\d+)?)/i,Ye=/\d+([_-~,.]\d+)?/,Ge=/[_-~,]/;function Ze(a){const e=a.match(He);if(e)return{volStr:e[0],volValueStr:e[4]};const t=a.match(Je);return t?{volStr:t[0],volValueStr:t[1]}:{}}function P(a){if(!a)return;if(!isNaN(+a))return{chap:+a};const{volStr:e,volValueStr:t}=Ze(a),r=e?a.replace(e,"").trim():a,s=r.match(Qe),n=r.match(Ye),i=s?.[6],o=i??n?.[0];if(!o)return;const l=+o.replace(Ge,".");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}}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),Ke(a)}function Ke(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 Xe=[{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:"ann",it:"anno",es:"a\xF1o"}}];function K(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=Xe.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=X(i)??X(i,["a","an"]);if(!o)return;const l=r-o*n.seconds*1e3;return l>0?l:void 0}function X(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 ee(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 te(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 et(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 d=10-r.length;if(d>0){const w=l+d<=a.length?a.slice(l,l+d):t.slice(0,d);r.push(...w)}break}const c=a[l],u=c.id!==void 0,g=t.findIndex(d=>u&&d.id===c.id||d.slug===c.slug||d.name==c.name),p=g===-1?void 0:t.splice(g,1)[0];!p||p.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 tt(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 $=(a=>(a.title="title",a.reader="reader",a.releases="releases",a.chapters="chapters",a.search="search",a))($||{}),at=Object.defineProperty,rt=(a,e,t)=>e in a?at(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,D=(a,e,t)=>(rt(a,typeof e!="symbol"?e+"":e,t),t);class k{constructor(e){D(this,"siteId"),D(this,"spec"),D(this,"siteMeta"),D(this,"tags"),D(this,"context"),D(this,"methodsMap",{[$.title]:()=>this.getRawTitleData(),[$.reader]:()=>this.getRawReaderData(),[$.releases]:()=>this.getRawReleasesData(),[$.search]:()=>this.getRawSearchData(),[$.chapters]:()=>this.getRawChaptersData()}),D(this,"normalizedTagsMap"),this.siteId=e.siteId,this.spec=e.spec,this.siteMeta=e.siteMeta,this.tags=e.tags,this.context=e.context}async getRawSearchData(){throw new Error("Unimplemented")}async getRawPageByType(e,t=!1){const r=await this.methodsMap[e](),s=!r&&(e===$.title||e===$.reader)&&await nt(this.spec);if(t&&!r&&!s)return;const n=location.origin+location.pathname;return{type:e,is404:s,specId:this.spec.id,siteName:h(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}")],g=e.replace("{lang}",l).replace("{titleId}",c).replace("{titleSlug}",u);if(n.startsWith(g))return{basePath:g,lang:l.toLowerCase(),titleId:c,titleSlug:u,slug:n.replace(g,"")}}}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=S(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=tt(e.rawReleases,t);if(r.length)return this.context?.oldRawReleases?et(r,this.context.oldRawReleases):{rawReleases:r,hasMore:!0}}getTagIdsFromNames(e){if(!e?.length)return;const t=this.normalizedTagsMap??(this.normalizedTagsMap=st(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)}}D(k,"specId"),D(k,"siteId");function st(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 nt(a){return it()===404||a[404]&&await x(a[404],{lazy:!0,timeoutMs:5e3})?!0:document.title.toLowerCase().includes("not found")}function it(){try{return window.performance.getEntries().find(a=>a.entryType==="navigation")?.responseStatus}catch{return}}class f extends k{async getRawReleasesData(){if(!this.spec?.releases?.title)return;const{chapter:e,...t}=this.spec.releases.title,r=await x(t.sel,{lazy:!0,all:!0});if(!r?.length)return;const s=r.slice(0,100).map(i=>{const o=h(t.url,i),l=S(o),c=h(t.name,i),u=h(t.at,i);if(!(!l||!c))return{titleEl:i,id:h(t.id,i),path:l,name:c,lang:h(t.lang,i)?.toLowerCase(),at:K(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,...g}=i,{id:p,slug:d}=this.parseTitleSlug(o);if(!d)return;const w=g.id||p,y=await this.getChapters(e,{root:l,titleId:w,titleSlug:d})??[];y.length&&n.push({slug:d,chapters:c||u?y.map(b=>({...b,elIndex:void 0,lang:b.lang??c,ts:b.ts??u})):y,...g,id:w})})),this.finalizeRawReleasesData({rawReleases:n})}getRawTitleData(){return this.getTitleData(this.spec.title)}async getTitleData(e){if(!e||(e.sel||e.lazy)&&!await x(e.sel??e.name,{lazy:!!e.lazy}))return;const t=h(e.name);if(!t)return;const{id:r,slug:s}=this.parseTitleSlug(location.pathname);if(!s)return;let n=_(e.tags)??[];n.length===1&&(n=n[0].split(",").map(p=>p.trim()).filter(Boolean));const i=h(e.type),o=_(e.langs)?.map(p=>p.toLowerCase()),l=r||h(e.id),c=await this.getChapters(e.chapter,{lazy:!0,titleId:l,titleSlug:s})??[],u=e.img?await this.getValidImgSrc(e.img):void 0,g=u&&this.context?.includeImgBytes?await Q(u):void 0;return{id:l||h(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:g,firstUrl:this.getFirstChapterUrl()}}getFirstChapterUrl(){const e=h(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 O(33,30,()=>{const t=h(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=h(e.name,t),s=h(e.url,t),{slug:n,id:i}=this.parseTitleSlug(s),o=ee(h(e.img,t));if(!(!r||!s||!n))return{name:r,img:o,url:s,slug:n,id:i||h(e.id)}}async getRawReaderData(){const{spec:e,siteMeta:t}=this;if(!e?.reader||e.generic&&!await f.isReaderPage(e.reader))return;const r=e.reader.content;if(!(!r||await f.verifyImgsCotainer(r)))return;const s=this.getRawReaderTitleData();if(!s)return;const{id:n,slug:i}=s,o=!!this.context?.disableLazyChapters,l=!!this.context?.includeHiddenChapters,c=await this.getChapters(e.reader?.chapter,{titleId:n,titleSlug:i,lazy:l||!o,includeHiddenChapters:l,timeoutMs:l?3e3:12e4,includeIndex:!0})??[],u=h(e.reader.label)?.toLowerCase().replace(s.name.toLowerCase(),"");if(!u)return;const{vol:g,chap:p=0}=P(u)||{},{slug:d,basePath:w,lang:y,titleId:b}=this.parseReaderSlug(te(t.readerBase,{titleId:n,titleSlug:i}),location.pathname,location.href),v=e.reader?.chapter,m=this.findNeighborChapter({sel:e.reader.prev,basePath:w}),C=this.findNeighborChapter({sel:e.reader.next,basePath:w});return this.finalizeRawReaderData({vol:g,chap:p,lang:y??h(e.reader.lang)?.toLowerCase()??(e.reader.lang?this.siteMeta.defaultLang:void 0),slug:d,basePath:w,imgs:r?void 0:_(e.reader.imgs),title:{id:n||b||h(this.spec.reader?.title.id),url:s.url,slug:i,name:s.name,langs:y?[y]:void 0,img:s.img,chapters:c,hasMoreChapters:!!(v&&!c.length&&(v.trigger||m||C))}},{prevSlug:m,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 i=this.context?.lang,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=h(e.url,s),i=S(n),o=h(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=[],g=await x(e.sel,{root:t,all:!0,lazy:i,timeoutMs:o});if(!g?.length)return c?.click(),[];const p=(g??[]).map((v,m)=>({id:h(e.id,v),label:h(e.label,v),url:h(e.url,v),at:h(e.at,v),elIndex:m}));c?.click();const d=p.map(({label:v})=>P(v)),w=d[1]?.chap;!d[0]&&(w===void 0||w<=1)&&(d[0]={chap:0});const{readerBase:y}=this.siteMeta,b=te(y,{titleId:r,titleSlug:s});return d.forEach((v,m)=>{if(!v)return;const{id:C,url:T,at:F,elIndex:H}=p[m],R={...v,id:C,ts:K(F,this.siteMeta.defaultLang)};l&&(R.elIndex=H);const Be=T?.startsWith("http")&&!T.includes(`//${location.hostname}/`),J=Be?T:S(T);if(!J){u.push(R);return}if(Be){u.push({...R,slug:J});return}const{slug:Ia,lang:Ca}=this.parseReaderSlug(b,J,T);u.push({...R,slug:Ia,lang:Ca})}),z(u)}static async isReaderPage(e){return!!e.sel&&!!await x(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 x(t,{lazy:!0,all:!1})}findNeighborChapter({sel:e,basePath:t}){const r=h(e);if(!r||r.startsWith("#")||r.startsWith("/#"))return;const s=S(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=e.title.hasMoreChapters?e:{...e,title:{...e.title,chapters:[{id:e.id,vol:e.vol,inferVol:e.inferVol,chap:e.chap,slug:e.slug,lang:e.lang}]}},u=P(t),g=P(r);return!u&&!g?c:{...c,prev:u?{...u,slug:t}:void 0,next:g?{...g,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 ot=Object.defineProperty,lt=(a,e,t)=>e in a?ot(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,ct=(a,e,t)=>(lt(a,typeof e!="symbol"?e+"":e,t),t);class ae extends f{parseTitleSlug(e){return{slug:S(e)?.split("/").filter(Boolean)[1]}}}ct(ae,"specId","bato");function ut(){return Math.random().toString(16).slice(2)}async function gt({addListener:a,removeListener:e,transform:t,filter:r,handler:s,onTimeout:n,timeout:i,once:o}){return new Promise(l=>{a(g);const c=()=>o===!0&&e(g),u=i?setTimeout(()=>{c(),l(void 0),n?.()},i):void 0;async function g(p,...d){p=t?t(p):p,p!==void 0&&(!r||r(p,...d))&&(c(),l(p),s?.(p,...d),u&&clearTimeout(u))}})}async function ht(a){return(await gt({addListener:e=>window.addEventListener("message",e),removeListener:e=>window.removeEventListener("message",e),...a}))?.data}async function pt(a){const{receiverWindow:e,timeout:t,targetOrigin:r,event:s,args:n}=a,i={reqId:ut(),event:s,args:n};return(e||window)?.postMessage(i,r??"*"),(await ht({filter:o=>o?.data?.resId===i.reqId,timeout:t??3e4,once:!0}))?.result}const L={isAny:!0};function M(a,...e){return pt({event:"tk:fetchResult",args:{baseUrl:a,segments:e}})}var dt=Object.defineProperty,ft=(a,e,t)=>e in a?dt(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,mt=(a,e,t)=>(ft(a,typeof e!="symbol"?e+"":e,t),t);const re=class Ne extends f{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 M(`https://api.${location.host}`,"comic",L,"chapters");if(!t)return e;const r=t.url.split("/").filter(Boolean).slice(-2)[0],s=se(t.value),n=h("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??ee(h(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:Ne.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=se(await n.json());return i?{...i,lang:t,asc:!1}:void 0}catch{return}}};mt(re,"specId","comick");let wt=re;function se(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 vt=Object.defineProperty,yt=(a,e,t)=>e in a?vt(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,bt=(a,e,t)=>(yt(a,typeof e!="symbol"?e+"":e,t),t);class ne extends f{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(Rt).filter(Boolean)}}}bt(ne,"specId","lua");function Rt(a){if(!a||typeof a.chapter_name!="string")return;const e=P(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 ie(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 $t=Object.defineProperty,St=(a,e,t)=>e in a?$t(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,xt=(a,e,t)=>(St(a,typeof e!="symbol"?e+"":e,t),t);class q extends f{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=oe(this.spec.reader?.title);if(!e)return;const t=this.finalizeNewSiteMeta(this.siteMeta,{titleBase:this.extractBasePath(S(e))});this.siteMeta=t??this.siteMeta;const r=await super.getRawReaderData();if(r)return{...r,siteMeta:t}}async getRawSearchData(){const e=oe(this.spec.search?.title);if(!e)return;const t=this.finalizeNewSiteMeta(this.siteMeta,{titleBase:this.extractBasePath(S(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=S(h(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 ie(e,"/").split("/").slice(0,-1).join("/")}}xt(q,"specId","madara");function oe(a){if(!a)return;const e=a.sel?document.querySelector(a.sel)??void 0:void 0;return h(a.url,e)}var Dt=Object.defineProperty,Mt=(a,e,t)=>e in a?Dt(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,It=(a,e,t)=>(Mt(a,typeof e!="symbol"?e+"":e,t),t);class le extends f{async getRawReleasesData(){const e=await this.getVM();if(!e)return super.getRawReleasesData();const t=e.LatestJSON.slice(0,100).map(r=>{const s=r.IndexName;return{slug:s,name:r.SeriesName,chapters:[V(r,s)]}});return this.finalizeRawReleasesData({rawReleases:t})}parseTitleSlug(e){const{slug:t}=super.parseTitleSlug(e);return!t||t.includes("{")?{}:{slug:t}}async getRawTitleData(){const e=await super.getRawTitleData();return e&&{...e,chapters:ce(await this.getVM(),e.slug),hasMoreChapters:!1}}parseReaderSlug(e,t){const{slug:r,basePath:s}=super.parseReaderSlug(e,t);return{slug:r.replace(/-page-\d{1,3}\.html\/?$/,".html"),basePath:s}}async getRawReaderData(){const e=await this.getVM();if(!e)return;const t=document.querySelector(".ImageGallery img.img-fluid")?.getAttribute("ng-src"),r=e.IndexName,s=V(e.CurChapter,r);return this.finalizeRawReaderData({chap:s.chap,slug:s.slug,imgs:Tt(e,t??void 0),basePath:"/"+this.siteMeta.readerBase.replace("{titleSlug}",r)+"/",title:{name:e.SeriesName,slug:r,url:`/${this.siteMeta.titleBase}/${r}`,chapters:ce(e,r),hasMoreChapters:!1}})}getVM(){return O(50,100,()=>window.angular?.element?.(document.documentElement)?.scope()?.vm)}}It(le,"specId","manga4life");function ce(a,e){return(a?.Chapters??a?.CHAPTERS??[]).sort((t,r)=>r.Chapter-t.Chapter).map(t=>V(t,e))}function V(a,e){const t=+a.Chapter[0],r=+a.Chapter.substring(1)/10;return{slug:`${e}-chapter-${r}${t&&t>1?`-index-${t}`:""}.html`,chap:r,ts:Ct(a.Date)}}function Ct(a){const e=new Date(a).valueOf();return e===e?e:void 0}function Tt(a,e){let t=e?.split(".").slice(-1)[0]??"png";t=t.length>=3&&t.length<=4?t:"png";try{const r=a.CurChapter.Chapter.slice(1,-1),s=a.CurChapter.Chapter[a.CurChapter.Chapter.length-1],n=s!=="0"?`${r}.${s}`:r,i=`https://${a.CurPathName}/manga/${a.IndexName}/${a.CurChapter.Directory?`${a.CurChapter.Directory}/`:""}${n}-`;return a.Pages.map(o=>{const l=(o+"").padStart(3,"0");return`${i}${l}.${t}`})}catch{return}}var Pt=Object.defineProperty,Bt=(a,e,t)=>e in a?Pt(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,Nt=(a,e,t)=>(Bt(a,typeof e!="symbol"?e+"":e,t),t);const Ot={a:.1,b:.2,c:.3,d:.4};class ue extends k{parseTitleSlug(e){return{slug:S(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:g})=>g==="manga"),o=I(s.volume),l=I(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([M(e,L),M(e,L,"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:g,title:p,volume:d,chapter:w,translatedLanguage:y}=c;return{slug:g||u,label:p||void 0,vol:I(d),chap:I(w),lang:y||"en",ts:new Date(c.readableAt).valueOf()}}).filter(l=>l?.chap!=null)??[],{data:n}=t.value;if(!n)return;const i=he({data:n,getTagIdsFromNames:l=>this.getTagIdsFromNames(l)});if(!i)return;const o=this.context?.includeImgBytes&&i.img?await Q(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([M(e,"chapter",L),M(e,"at-home","server",L),M(e,"manga",L,"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:g,dataSaver:p,hash:d}}=r.value,w=n.relationships?.find?.(R=>R.type==="manga");if(!w)return;const y=he({data:w,getTagIdsFromNames:R=>this.getTagIdsFromNames(R)});if(!y||typeof s.value.volumes!="object")return;const b=ge(s.value)??[];(typeof o!="string"||o==="none")&&!b.length&&b.push({chap:0,slug:n.id});const v=b.findIndex(R=>R.slug===n.id),m=n.relationships?.find?.(R=>R.type==="scanlation_group"),C=u.endsWith("/")?u:u+"/",T=!!localStorage.getItem("md")?.includes?.('"dataSaver":true'),F=`${C}${T?"data-saver":"data"}/`,H=((T?p:g)??[]).map?.(R=>`${F}${d}/${R}`)??[];return{externalUrl:l,vol:I(i),inferVol:b[v]?.inferVol,chap:I(o)||0,imgs:H,lang:c,slug:n.id,prev:b[v+1],next:b[v-1],basePath:"/chapter/",groupName:m?.attributes?.name,groupUrl:m?.attributes?.website,isWebtoon:w?.attributes?.tags?.some(R=>R.attributes.name.en==="Long Strip"),title:{...y,chapters:b}}}async getRawChaptersData(){if(!this.context)return;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=ge(await s.json())}catch{return}if(r)return{chapters:r,lang:t,asc:!1,hasMore:!1,total:r.length}}}Nt(ue,"specId","mangadex");function I(a){if(typeof a!="string"||a==="none")return;const e=parseFloat(a);if(e!==e)return;const t=a[a.length-1];return e+(Ot[t]??0)}function ge(a){if(typeof a.volumes!="object")return;const e=Object.values(a.volumes).map(({volume:t,chapters:r})=>{const s=I(t);return Object.values(r).map(({id:n,chapter:i})=>{const o=I(i);if(o!==void 0)return{vol:s,chap:o,slug:n}})}).flat().filter(Boolean).reverse();return z(e)}function he({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 g=jt(),p=(i??[])?.map?.(m=>typeof m=="string"?m:void 0).filter(Boolean)??[],d=p.filter(m=>m&&(!g||g.includes(m))),w=o?.map?.(m=>{const[[,C]=[]]=Object.entries(m);return C}),y=s?.find?.(m=>m.type==="cover_art")?.attributes?.fileName,b=y?`https://mangadex.org/covers/${t}/${y}.256.jpg`:void 0,v=(l||[]).map(m=>m?.attributes?.name?.en).concat(c).filter(Boolean);return{url:`${location.origin}/title/${t}`,slug:t,name:u,altNames:w,langs:d.length>0?d:p.length>0?p:["en"],img:b,tags:e(v)}}function jt(){const a=localStorage.getItem("md");if(a)try{const e=JSON.parse(a)?.userPreferences?.filteredLanguages;return e?.length?e:void 0}catch{return}}var Lt=Object.defineProperty,_t=(a,e,t)=>e in a?Lt(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,zt=(a,e,t)=>(_t(a,typeof e!="symbol"?e+"":e,t),t);class pe extends f{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 x(".current-viewtype",{lazy:!0,all:!1}))?.textContent?.trim().toLowerCase()!=="volume")return await super.getRawReaderData()}async getRawChaptersData(){const e=this.context?.lang;if(!e)return;const t=await x(`.tab-content[data-name="chapter"] a.dropdown-item[data-code="${e.toUpperCase()}"]`,{lazy:!0,all:!1});if(t)return t.click(),await x(`.tab-content[data-name="chapter"] li.item[data-number] a[href*="/${e}/"]`,{lazy:!0,all:!1}),await super.getRawChaptersData()}}zt(pe,"specId","mangafire");var At=Object.defineProperty,kt=(a,e,t)=>e in a?At(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,Wt=(a,e,t)=>(kt(a,typeof e!="symbol"?e+"":e,t),t);class de extends f{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 O(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(",")}}Wt(de,"specId","mangago");var Et=Object.defineProperty,Ut=(a,e,t)=>e in a?Et(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,qt=(a,e,t)=>(Ut(a,typeof e!="symbol"?e+"":e,t),t);class fe extends f{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]}))}}}qt(fe,"specId","mangaplus");var Vt=Object.defineProperty,Ft=(a,e,t)=>e in a?Vt(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,Ht=(a,e,t)=>(Ft(a,typeof e!="symbol"?e+"":e,t),t);class me extends f{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}))}}}Ht(me,"specId","mangareader");var Jt=Object.defineProperty,Qt=(a,e,t)=>e in a?Jt(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,Yt=(a,e,t)=>(Qt(a,typeof e!="symbol"?e+"":e,t),t);class we 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:ie(location.pathname,"/")},s=e.title,n=document.querySelector(s.sel)??void 0;if(!n)return;const i=S(h(s.url,n));if(i===void 0)return;const o=n.querySelector(s.chapter.sel)??void 0;if(!(!o||S(h(s.chapter.url,o))===void 0))return r.titleBase=this.extractBasePath(i),t.titleIdType===E.id&&(h(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}}Yt(we,"specId","mangastream");var Gt=Object.defineProperty,Zt=(a,e,t)=>e in a?Gt(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,Kt=(a,e,t)=>(Zt(a,typeof e!="symbol"?e+"":e,t),t);class ve extends f{async getRawReaderData(){const e=await super.getRawReaderData();if(e)return{...e,title:{...e.title,name:e.title.name.replace("Ritorna a","").trim()}}}}Kt(ve,"specId","mangaworld");var Xt=Object.defineProperty,ea=(a,e,t)=>e in a?Xt(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,ta=(a,e,t)=>(ea(a,typeof e!="symbol"?e+"":e,t),t);class ye extends f{async getRawTitleData(){const e=await super.getRawTitleData();if(e)return{...e,hasMoreChapters:e.chapters.length===50}}}ta(ye,"specId","mgeko");var aa=Object.defineProperty,ra=(a,e,t)=>e in a?aa(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,sa=(a,e,t)=>(ra(a,typeof e!="symbol"?e+"":e,t),t);class be extends f{async getRawTitleData(){const e=await super.getRawTitleData();if(!e)return e;const t=await M(`https://api.${location.host}`,"chapter","query");if(!t)return;let r;try{r=new URL(t.url).searchParams.get("series_id")}catch{return}if(!r)return;const{first_page:s,last_page:n}=t.value.meta||{};return{...e,id:r,hasMoreChapters:s!==n}}async getRawChaptersData(){if(!this.context?.rawId)return;const{rawId:e}=this.context;try{const t=await(await fetch(`https://api.${location.host}/chapter/query?page=1&perPage=1000&query=&order=desc&series_id=${e}`)).json();if(!t?.data?.map)return;const r=[];return t.data.forEach(s=>{const{chapter_name:n,chapter_slug:i,created_at:o}=s;if(typeof n!="string"||typeof i!="string")return;const l=P(n);if(l?.chap)return{...l,slug:i,ts:o&&new Date(o).valueOf()||void 0}}),{chapters:r,hasMore:!1,asc:!1}}catch{return}}}sa(be,"specId","reaper");var na=Object.defineProperty,ia=(a,e,t)=>e in a?na(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,oa=(a,e,t)=>(ia(a,typeof e!="symbol"?e+"":e,t),t);class Re extends f{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 $e({...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:{...$e({...e.title,url:t,tags:[]},".episode-list .js-ep-cnt"),hasMoreChapters:!1}}}async getRawChaptersData(){if(!this.context)return;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 la(await n.json())}catch{return}}parseTitleSlug(e){if(!e)return{};const t=e.split("/").filter(Boolean);return{slug:t[1]??t[0]}}}oa(Re,"specId","tapas");function $e(a,e){const t=ca(e)>20;return{...a,chapters:t?[]:a.chapters,hasMoreChapters:t}}function la(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 ca(a){return+(document.querySelector(a)?.textContent?.trim().split(" ")[0]||0)}var ua=Object.defineProperty,ga=(a,e,t)=>e in a?ua(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,ha=(a,e,t)=>(ga(a,typeof e!="symbol"?e+"":e,t),t);class Se extends f{async getRawReleasesData(){const e=await super.getRawReleasesData();if(e)return{...e,rawReleases:e.rawReleases.map(t=>({...t,id:pa(t.slug)}))}}}ha(Se,"specId","truyenqq");function pa(a){return a.substring(a.lastIndexOf("-")+1).replace(".html","")||void 0}var da=Object.defineProperty,fa=(a,e,t)=>e in a?da(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,ma=(a,e,t)=>(fa(a,typeof e!="symbol"?e+"":e,t),t);class xe extends f{async getRawTitleData(){const e=await super.getRawTitleData();return e?.img?{...e,img:wa(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=M(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 g=De(n.value);return g?{chapters:g,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=De(await c.json());if(u)return{chapters:u,title:e,total:l,skip:0,hasMore:!1}}}ma(xe,"specId","vortex");function wa(a){try{return new URL(a,location.href).searchParams.get("url")||void 0}catch{return}}function De(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 va=Object.defineProperty,ya=(a,e,t)=>e in a?va(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,ba=(a,e,t)=>(ya(a,typeof e!="symbol"?e+"":e,t),t);class Me extends f{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=P(h(".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(g=>({...g,lang:u})),hasMoreChapters:!1}}}async getReaderImgs(){const e=_("#_imageList img|[attr:data-url,attr:src]");return e?.length?e:await O(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}}}ba(Me,"specId","webtoon");var Ra=Object.defineProperty,$a=(a,e,t)=>e in a?Ra(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,Sa=(a,e,t)=>($a(a,typeof e!="symbol"?e+"":e,t),t);class Ie extends f{async getRawChaptersData(){const e=this.context?.rawId;if(!e)return;const t=await xa(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}}}Sa(Ie,"specId","weebcentral");async function xa(a){const e=`https://weebcentral.com/series/${a}/full-chapter-list`;try{return await(await fetch(e)).text()}catch{return}}const Da=[ae,wt,ne,q,le,ue,pe,de,fe,me,we,ve,ye,be,Re,xe,Se,Me,Ie];function Ce(a){const e=Da.find(t=>t.specId===a.spec.id)??f;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]:Te(t,e.generic);if(!r.length)return;const s=Ce({...a,spec:e,siteMeta:t});return await N(r.map(n=>s.getRawPageByType(n,r.length>1)))}return await N((a.genericSpecs??[]).map(t=>{const r=Te(t.meta,t.generic);if(!r.length)return[];const s=Ce({...a,spec:t,siteMeta:t.meta});return r.map(n=>s.getRawPageByType(n,!0))}).flat())}function Te(a,e){if(location.pathname==="/")return[];const{titleBase:t,readerBase:r}=a,s=location.pathname.split("/").filter(Boolean),n=Pe(s,r),i=Pe(s,t);if(n&&i)return[$.reader,$.title];const o=[];return!i&&(n!==!1||e)&&o.push($.reader),!n&&(i!==!1||e)&&o.push($.title),!o.length&&e?[$.reader,$.title]:o}function Pe(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}B.PageType=$,B.scrape=Ma});
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "trackkun-dom",
3
3
  "author": "endyquang",
4
- "version": "1.11.1",
4
+ "version": "1.11.2",
5
5
  "license": "UNLICENSED",
6
6
  "description": "Trkun DOM parser",
7
7
  "main": "index.js",