trackkun-dom 2.10.3 → 2.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +1 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(A,E){typeof exports=="object"&&typeof module<"u"?E(exports):typeof define=="function"&&define.amd?define(["exports"],E):(A=typeof globalThis<"u"?globalThis:A||self,E(A._trackkun_={}))})(this,function(A){"use strict";function E(a){let e=!1;return new Promise((t,r)=>{Promise.all(a.map(async n=>{const s=await n;!e&&s&&(e=!0,t(s))})).then(()=>{e||t(void 0)})})}async function D(a,e,t){const r=await t(()=>{a=0});if(r!==void 0)return r;if(!(a<=0))return await new Promise(n=>{setTimeout(async()=>{const s=await D(a-1,e,t);n(s)},e)})}async function P(a,e,t=0){const r=e.root??document.documentElement,n=e.timeoutMs??1e4;return D(e.lazy===!0?n/50:0,50,()=>{const s=e.all===!0?Array.from(r.querySelectorAll(a)):r.querySelector(a)??void 0;return(e.all?!s?.length:!s)?void 0:s})}function G(a){if(a instanceof HTMLOptionElement){const e=a.parentElement instanceof HTMLOptGroupElement?a.parentElement.parentElement:a.parentElement;if(!e||!(e instanceof HTMLSelectElement))return;const t=a.getAttribute("value")||"";if(e.value===t)return;e.value=t,e.dispatchEvent(new Event("change"));return}a instanceof HTMLAnchorElement&&a.addEventListener("click",e=>e.preventDefault(),{once:!0}),a.click(),a.dispatchEvent(new PointerEvent("pointerdown",{bubbles:!0,cancelable:!0,pointerType:"mouse",button:0})),a.dispatchEvent(new MouseEvent("mousedown",{bubbles:!0,cancelable:!0,view:window,button:0}))}const te={text:Je,attr:Qe,"attr-contain":Ye,value:Ke,row:Ze,"bg-image":Xe},Ge={pattern:et,remove:tt,atob:at};function p(a,e){if(a)return ae(a,e,He)}function N(a,e){if(a)return ae(a,e,Ve)}function ae(a,e,t){if(!a)return;const r=a.split("||").map(n=>n.trim()).filter(n=>!!n&&n.includes("|"));for(const n of r){const s=Fe(n);if(!s)continue;const i=t(e??document.documentElement,s);if(i)return i}}function Fe(a){const[e,t,...r]=a.split("|");if(!t)return;const n=t?.startsWith("[")&&t.endsWith("]")?t.substring(1,t.length-1).split(","):[t];return{selector:e||void 0,extractors:n.map(re),transformers:r.map(re)}}function re(a){const e=a.indexOf(":"),t=e!==-1;return{fn:t?a.substring(0,e):a,param:t?a.substring(e+1):""}}function He(a,e){if(!e.selector)return ne(a,e);const t=e.selector.split(",");for(const r of t){const n=Array.from(a.querySelectorAll(r));for(const s of n){const i=ne(s,e);if(i)return i}}}function Ve(a,e){const t=e.selector?Array.from(a.querySelectorAll(e.selector)):[a],r=[];for(const n of t)for(const s of e.extractors){const i=te[s.fn],o=i(n,s.param);if(o){r.push(se(o,e.transformers));break}}if(r.length)return r}function ne(a,e){for(const t of e.extractors){const r=te[t.fn],n=r(a,t.param);if(n)return se(n,e.transformers)}}function se(a,e){let t=a;for(const r of e){const n=Ge[r.fn];n&&(t=n(t,r.param).trim())}return t}function Je(a){return Array.from(a.childNodes).filter(e=>e.nodeType===3).map(e=>_(e.textContent)).filter(Boolean).join(" ").trim()||_(a.textContent)}function Qe(a,e){return _(a.getAttribute(e))}function Ye(a,e){let t=a.getAttribute(e);if(!t){const r=a.getAttributeNames().find(n=>n.includes(e));r&&(t=a.getAttribute(r))}return _(t)}function Ke(a){return a.value}function Ze(a,e){if(!e)return;const t=_(a.textContent)?.toLowerCase(),r=e.toLowerCase();if(!(t!==r&&t!==`${r}:`))return _(a.nextElementSibling?.textContent??a.nextSibling?.textContent)}function Xe(a){const e=getComputedStyle(a).backgroundImage;if(!(!e||!e.startsWith("url(")))return e.slice(5,-2)||void 0}function _(a){if(a)return a?.replace(/(\n|\t)/g," ").trim()||void 0}function et(a,e){if(e)try{return a.replace(new RegExp(e,"i"),"$1")}catch{}return a}function tt(a,e){if(e)try{return a.replaceAll(new RegExp(e,"gi"),"")}catch{}return a}function at(a){try{return window.atob(a)}catch{return a}}var rt=(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))(rt||{}),nt=(a=>(a[a.ok=1]="ok",a[a.hidden=2]="hidden",a[a.deleted=3]="deleted",a))(nt||{}),st=(a=>(a[a.aggregator=0]="aggregator",a[a.scanlator=1]="scanlator",a))(st||{}),it=(a=>(a[a.pending=0]="pending",a[a.completed=1]="completed",a[a.offline=2]="offline",a[a.incompat=3]="incompat",a))(it||{}),F=(a=>(a.id="id",a.name="name",a.slug="slug",a))(F||{}),q=(a=>(a.blank="about:blank",a.title="meta.title",a.reader="meta.reader",a))(q||{});function ie(a=0){return new Promise(e=>setTimeout(e,a))}const lt=/(vol(ume)?|season)(\s*|-|\.)(\d+)/i,ot=/^S([1-9])\s/i,ct=/(ch(ap(t(er)?|\.)?|\.)?|#|episode\.?|capitolo\.?|capitulo\.?|bölüm\.?)(\s*|-)(\d+([_-~,.]\d+)?)/i,ut=/\d+([_-~,.]\d+)?/,gt=/[_-~,]/;function pt(a){const e=a.match(lt);if(e)return{volStr:e[0],volValueStr:e[4]};const t=a.match(ot);return t?{volStr:t[0],volValueStr:t[1]}:{}}function C(a){if(!a)return;if(!isNaN(+a))return{chap:+a};const{volStr:e,volValueStr:t}=pt(a),r=e?a.replace(e,"").trim():a,n=r.match(ct),s=r.match(ut),i=n?.[6],o=i??s?.[0];if(!o)return;const l=+o.replace(gt,".");if(isNaN(l))return;const c=e&&t&&!isNaN(+t)&&a.indexOf(e)<a.indexOf(i?n[0]:s[0])?+t:void 0;return{vol:c===void 0||c<=0?void 0:c,chap:l}}async function U(a,e=240){return new Promise(t=>{const r=new Image;r.crossOrigin="anonymous",r.onerror=()=>t(void 0),r.onload=()=>{const n=document.createElement("canvas"),s=n.getContext("2d"),i=Math.max(1,r.naturalWidth/e),o=r.naturalWidth/i,l=r.naturalHeight/i;n.width=o,n.height=l;const c=/iPad|iPhone|iPod/.test(navigator.userAgent);try{s.drawImage(r,0,0,o,l);const u=n.toDataURL(c?"image/jpg":"image/webp",c?.99:.8).split(",").slice(-1)[0];t(u)}catch{t(void 0)}},r.src=a})}async function dt(a,e=240){const t=await ht(a);if(t)return await new Promise(async r=>{const n=U(t,e),s=setTimeout(()=>r(void 0),100),i=await n;clearTimeout(s),r(i)})}async function ht(a){if(a.startsWith("blob:"))return a;try{const e=await fetch(a);if(e.status>=400)return;const t=await e.blob();return URL.createObjectURL(t)}catch{return}}function B(a,e){a.sort((l,c)=>l.vol===void 0||c.vol===void 0?c.chap-l.chap:c.vol-l.vol||c.chap-l.chap);const t={},r={};for(let l=a.length-1;l>=0;l--){const c=a[l],u=c.group??"";t[u]=(t[u]??0)+1;const g=c.lang??"";c.vol!==void 0?r[g]=c.vol:r[g]!==void 0&&(c.inferVol=r[g])}const n=[],s={},i=e?.preferGroup,o=l=>l.lang??"";for(const l of a){const c=o(l),u=s[c],g=n[u];if(!(g&&g.chap===l.chap&&(g.vol===l.vol||g.vol===void 0||l.vol===void 0))){s[c]=n.length,n.push(l);continue}if(!i){g.vol===void 0&&l.vol!=null&&(n[u]=l);continue}g.group!==i&&(l.group==i||g.group&&!l.group||t[l.group??""]>t[g.group??""])&&(n[u]=l)}return n}const ft=[{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 le(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 n=new Date(t);if(n instanceof Date){const c=n.valueOf();if(!isNaN(c))return n.getHours()===0&&n.getMinutes()===0?Math.min(r,c+432e5):c}const s=ft.find(c=>e&&c.locales[e]&&t.indexOf(c.locales[e])!==-1?!0:t.indexOf(c.locales.en)!==-1);if(!s)return;const i=t.split(" ").filter(Boolean),o=oe(i)??(e==="en"?oe(i,["a","an"]):void 0);if(!o)return;const l=r-o*s.seconds*1e3;return l>0?l:void 0}function oe(a,e){for(let t=0;t<a.length;t++){const r=a[t];if(e?.includes(r))return 1;const n=+r;if(n)return n<0?void 0:n}}function mt(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 wt(a,{titleSlug:e,titleId:t,lang:r}){if(!a)return"/";let n=a;return e&&(n=n.replace("{titleSlug}",e)),t&&(n=n.replace("{titleId}",t)),r&&(n=n.replace("{lang}",r)),n.endsWith("/")||(n+="/"),n.startsWith("/")||(n="/"+n),n}function H(a){if(!a)return;let e=a;e.startsWith("//")&&(e=`https:${e}`);try{return new URL(e)}catch{return}}function x(a){if(!(!a||typeof a!="string"))return a.includes("//")?H(a)?.pathname:a}function vt(a,e){const t=[...e],r=[];let n=!1,s=0;const i=Math.min(a.length,100);for(let l=0;l<i;l++){if(s>=10/2){const f=10-r.length;if(f>0){const h=l+f<=a.length?a.slice(l,l+f):t.slice(0,f);r.push(...h)}break}const c=a[l],u=c.id!==void 0,g=t.findIndex(f=>u&&f.id===c.id||f.slug===c.slug||f.name==c.name),d=g===-1?void 0:t.splice(g,1)[0];!d||d.chapters[0]?.chap!==c.chapters[0]?.chap?(n=!0,r.push({...c,changed:!0})):(s++,r.push(c))}if(!n)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 yt(a,e){const t={};return a.forEach(r=>{const n=r.chapters.reduce((s,i)=>{const o=i.lang||e||"";return s[o]||(s[o]=[]),s[o].push(i),s},{});Object.entries(n).forEach(([s,i])=>{const o=`${r.slug}:${s}`;t[o]?(t[o].chapters.push(...i),B(t[o].chapters)):t[o]={...r,lang:s===""?void 0:s,chapters:i}})}),Object.values(t)}var R=(a=>(a.title="title",a.reader="reader",a.releases="releases",a.chapters="chapters",a.search="search",a))(R||{}),bt=Object.defineProperty,Rt=(a,e,t)=>e in a?bt(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,M=(a,e,t)=>(Rt(a,typeof e!="symbol"?e+"":e,t),t);class W{constructor(e){M(this,"headless"),M(this,"siteId"),M(this,"spec"),M(this,"siteMeta"),M(this,"tags"),M(this,"context"),M(this,"methodsMap",{[R.title]:()=>this.getRawTitleData(),[R.reader]:()=>this.getRawReaderData(),[R.releases]:()=>this.getRawReleasesData(),[R.search]:()=>this.getRawSearchData(),[R.chapters]:()=>this.getRawChaptersData()}),M(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 getRawPageByType(e,t=!1){const r=await this.methodsMap[e](),n=!r&&(e===R.title||e===R.reader)&&await St(this.spec);if(t&&!r&&!n)return;const s=location.origin+location.pathname;return{type:e,is404:n,specId:this.spec.id,siteName:Dt(this.spec.name),favUrl:Mt(),htmlLang:Tt(),url:s,data:r,spec:this.spec,context:this.context}}parseReaderSlug(e,t,r){const n=e.includes("{"),s=!this.siteId;let i=t;if(i[0]!=="/"&&(i.includes("/")||s&&!n))try{i=new URL(t,location.href).pathname}catch{}if(i.endsWith("/")&&(i=i.slice(0,-1)),e.startsWith("/")||(e="/"+e),e.endsWith("/")||(e=e+"/"),n){const o=e.split("/").filter(Boolean),l=i.split("/").filter(Boolean);if(o.length<l.length){const c=l[o.indexOf("{lang}")]?.toLowerCase(),u=l[o.indexOf("{titleId}")],g=l[o.indexOf("{titleSlug}")],d=e.replace("{lang}",c).replace("{titleId}",u).replace("{titleSlug}",g);if(s)return{basePath:"",slug:i,lang:c,titleId:u,titleSlug:g};if(i.startsWith(d))return{basePath:d,slug:i.replace(d,""),lang:c,titleId:u,titleSlug:g}}}else if(!s&&i.startsWith(e))return{basePath:e,slug:i.replace(e,"")};return{basePath:"",slug:i}}parseTitleSlug(e){if(typeof e!="string")return{};const t=x(e),r=t?.split("/").filter(Boolean);if(!r?.length)return{};const n=this.siteMeta.titleBase.split("/").filter(Boolean),s=n.indexOf("{slug}");return(s===-1?r.length-n.length>=1:r.length===n.length)?{id:r[n.indexOf("{id}")],slug:this.siteId?s===-1?r.slice(n.length).join("/"):r[s]:t}:{slug:t}}finalizeRawReleasesData(e){const t=this.spec.releases?.title?.lang?this.siteMeta.defaultLang:void 0,r=yt(e.rawReleases,t);if(r.length)return this.context.oldRawReleases?vt(r,this.context.oldRawReleases):{rawReleases:r,hasMore:!0}}getTagIdsFromNames(e){if(!e?.length)return;const t=this.normalizedTagsMap??(this.normalizedTagsMap=$t(this.tags)),r=e.map(n=>t[V(n)]).filter(Boolean);return r.length===0?void 0:Array.from(new Set(r)).sort((n,s)=>n-s)}}M(W,"specId"),M(W,"siteId");function $t(a){const e={};return a.forEach(({id:t,name:r,altNames:n})=>{e[V(r)]=t,n&&n.forEach(s=>{e[V(s)]=t})}),e}function V(a){const e=a.toLowerCase().replaceAll(/[^a-z0-9\s]/gi,"").trim().replaceAll(/\s+/g," ");return e[e.length-1]==="s"?e.substring(0,e.length-1):e}async function St(a){return xt()===404||a[404]&&await P(a[404],{lazy:!0,timeoutMs:5e3})?!0:document.title.toLowerCase().includes("not found")}function xt(){try{return window.performance.getEntries().find(a=>a.entryType==="navigation")?.responseStatus}catch{return}}function Dt(a){return(a&&p(a))??p('meta[property="og:site_name"]|attr:content')}function Mt(){return p('link[rel="icon"][sizes="32x32"],link[rel="icon"][sizes="192x192"],link[rel="apple-touch-icon"]|attr:href')}function Tt(){return p("html|attr:lang")||"en"}class w extends W{async getRawReleasesData(){if(!this.spec?.releases?.title)return;const{chapter:e,...t}=this.spec.releases.title,r=await P(t.sel,{lazy:!0,all:!0});if(!r?.length)return;const n=Date.now(),s=r.slice(0,100).map(o=>{const l=p(t.url,o),c=x(l),u=p(t.name,o),g=p(t.at,o);if(!c||!u)return;const d=le(g,this.siteMeta.defaultLang);return{titleEl:o,id:p(t.id,o),path:c,name:u,lang:p(t.lang,o)?.toLowerCase(),at:d?Math.min(d,n):void 0}}).filter(Boolean);if(!s.length)return;const i=[];return await Promise.all(s.map(async o=>{const{path:l,titleEl:c,lang:u,at:g,...d}=o,{id:f,slug:h}=this.parseTitleSlug(l);if(!h)return;const v=d.id||f,y=await this.getChapters(e,{root:c,titleId:v,titleSlug:h,lang:u})??[];y.length&&i.push({slug:h,chapters:u||g?y.map($=>({...$,elIndex:void 0,lang:$.lang??u,ts:$.ts??g})):y,...d,id:v})})),this.finalizeRawReleasesData({rawReleases:i})}getRawTitleData(){return this.getTitleData(this.spec.title)}async getTitleData(e){if(!e||(e.sel||e.lazy)&&!await P(e.sel??e.name,{lazy:!!e.lazy}))return;const t=p(e.name);if(!t)return;const{id:r,slug:n}=this.parseTitleSlug(location.pathname);if(!n)return;const s=N(e.tags)?.map(h=>h.split(",")).flat().map(h=>h.trim()).filter(Boolean),i=p(e.type),o=N(e.langs)?.map(h=>h.toLowerCase()),l=r||p(e.id),c=await this.getChapters(e.chapter,{lazy:!0,titleId:l,titleSlug:n,preferGroup:this.context.preferGroup})??[],u=await this.getValidImgSrc(e.img,t),g=u&&this.context.includeImgBytes?await dt(u):void 0,d=this.getFirstChapterUrl(),f=e.firstBtn;return{id:l||p(e.id),url:location.origin+location.pathname,slug:n,name:t,langs:o?.length?o:e.langs&&this.siteMeta.defaultLang?[this.siteMeta.defaultLang]:void 0,tags:this.getTagIdsFromNames([...s??[],...i?[i]:[]]),chapters:c,hasMoreChapters:e.hasMore?!!document.querySelector(e.hasMore):void 0,img:u,imgBytes:g,firstUrl:d,firstBtn:!d&&f&&document.querySelector(f)?f:void 0,trackers:this.getTrackersMap(e.trackers)}}getTrackersMap(e){if(!e)return;const t=p(e.mal),r=p(e.anl);if(!t||!r)return;const n={};return t&&(n.mal=t),r&&(n.anl=r),n}getFirstChapterUrl(){const e=p(this.spec.title?.first);if(e){if(e.startsWith("http"))return e;try{return new URL(e,location.href).href}catch{return}}}getValidImgSrc(e,t){return D(33,30,()=>{const r=p(e)||p(`img[alt="${t.replaceAll('"',"")}"]|[attr:data-src,attr-contain:src]`);return!r||r.startsWith("data:")?void 0:document.querySelector(`img[srcset*="${r}"]`)?r.split(" ")[0]:r})}getRawReaderTitleData(e){const t=this.spec.reader?.title;if(!t)return;const r=t.sel?document.querySelector(t.sel)??void 0:void 0,n=p(t.name,r);if(!n)return;const s=mt(p(t.img,r));if(e?.slug){let c=this.siteMeta.titleBase;e?.id&&(c=c.replace("{id}",e.id));const u=c.includes("{slug}");if(u&&(c=c.replace("{slug}",e.slug)),!c.includes("{")){c=u?c:`${c}/${e.slug}`;const g=this.siteMeta.trailing?"/":"",d=`${location.origin}/${c}${g}`;return{name:n,img:s,url:d,slug:e.slug,id:e.id||p(t.id)}}}const i=p(t.url,r),{slug:o,id:l}=this.parseTitleSlug(i);if(!(!n||!i||!o))return{name:n,img:s,url:new URL(i,location.origin).href,slug:o,id:l||p(t.id)||e?.id}}async getRawReaderData(){const{spec:e,siteMeta:t}=this;if(!e?.reader||!await w.isReaderPage(e.reader,!!e.generic))return;const r=e.reader.content;if(!(!r||await w.verifyImgsCotainer(r)))return;const n=this.parseReaderSlug(t.readerBase,location.pathname,location.href),{slug:s,basePath:i,lang:o}=n,l=this.getRawReaderTitleData({id:n.titleId,slug:n.titleSlug});if(!l)return;const c=p(e.reader.group),{id:u,slug:g}=l,d=e.reader?.chapter,f=!!this.context.disableLazyChapters,h=!!this.context.includeHiddenChapters,v=await this.getChapters(d,{titleId:u,titleSlug:g,lang:o,lazy:h||!f,includeHiddenChapters:h,timeoutMs:h?3e3:29e3,includeIndex:!0,basePath:i,preferGroup:c||this.context.preferGroup})??[],y=p(e.reader.label)?.toLowerCase().replace(l.name.toLowerCase(),"");if(!y)return;const{vol:$,chap:b=0}=C(y)||{},I=this.findNeighborChapter({sel:e.reader.prev,basePath:i,titleUrl:l.url}),j=this.findNeighborChapter({sel:e.reader.next,basePath:i,titleUrl:l.url});return this.finalizeRawReaderData({vol:$,chap:b,lang:o??p(e.reader.lang)?.toLowerCase()??(e.reader.lang?this.siteMeta.defaultLang:void 0),slug:s,basePath:i,group:c??p(e.reader.group),imgs:N(e.reader.imgs),title:{id:u||p(this.spec.reader?.title.id),url:l.url,slug:g,name:l.name,langs:o?[o]:void 0,img:l.img,chapters:v,hasMoreChapters:!v.length&&!h&&!!this.context.disableLazyChapters&&!!d?.label}},{prevSlug:I,nextSlug:j})}async getRawChaptersData(){const e=this.siteMeta.chapters;if(e===q.blank)return;const t=e===q.reader,r=!e||e===q.title,n=t?(await this.getRawReaderData())?.title:r?await this.getRawTitleData():void 0,s=this.spec.chapters?.chapter,i=s?await this.getChapters(s,{titleId:n?.id,titleSlug:n?.slug,lazy:this.spec.chapters?.lazy,includeHiddenChapters:!0,lang:this.context.lang,preferGroup:this.context.preferGroup}):n?.chapters;if(!i)return;const{lang:o}=this.context,l=o?i.filter(c=>!c.lang||c.lang===o):i;return{chapters:l,title:n?{...n,chapters:[]}:await this.getTitleData(this.spec.chapters?.title),hasMore:!1,asc:!1,total:l.length}}async getRawSearchData(){const e=this.spec.search,t=this.context.lang;if(!e)return;e.delay&&await ie(e.delay);const r=e.title,{chapter:n}=r,s=[],i=e.lazy?e.empty||e.loading?550:100:1,o=await D(i,50,()=>{const l=Array.from(document.querySelectorAll(r.sel));if(l.length||e.empty&&document.querySelector(e.empty)||e.loading&&!document.querySelector(e.loading))return l});if(o)return await Promise.all(o.map(async l=>{const c=p(r.url,l),u=x(c),g=p(r.name,l),{slug:d,id:f}=this.parseTitleSlug(u);if(!u||!g||!d)return;const h=p(r.lang,l);h&&t&&h!==t||s.push({id:f||p(r.id,l),slug:d,name:g,img:p(r.img??"img|[attr:data-src,attr-contain:src]",l),lang:h,chapters:await this.getChapters(n,{root:l,titleId:f,titleSlug:d})??[]})})),{rawReleases:s}}async getChapters(e,{root:t,titleId:r,titleSlug:n,lang:s,includeHiddenChapters:i=!1,lazy:o=!0,timeoutMs:l,includeIndex:c,basePath:u,preferGroup:g}){const d=e?.sel;if(!d||!e.label)return;const f=d.includes("{titleSlug}")?n?d.replace("{titleSlug}",n):void 0:d;if(!f)return;let h;if(e.trigger&&(!i||(h=await P(e.trigger,{timeoutMs:5e3,lazy:!0}),!h)))return;const v=[],y=await D(l??(o?200:1),50,async()=>{h&&(G(h),await ie(50));const m=Array.from((t??document.documentElement)?.querySelectorAll(f));if(m.length)return m}),$=(y??[]).map((m,X)=>({id:p(e.id,m),label:p(e.label,m),url:p(e.url,m),at:p(e.at,m),lang:p(e.lang,m),group:p(e.group,m),elIndex:X})),b=(e.dismiss?(t??document.body).querySelector(e.dismiss):void 0)??h;if(b&&G(b),!y?.length)return[];const I=$.map(({label:m})=>C(m)),j=I[1]?.chap;!I[0]&&(j===void 0||j<=1)&&(I[0]={chap:0});const K=u??wt(this.siteMeta.readerBase,{titleId:r,titleSlug:n,lang:s}),Z=Date.now();return I.forEach((m,X)=>{if(!m)return;const{id:rr,url:z,at:nr,lang:sr,group:ir,elIndex:lr}=$[X],qe=le(nr,this.siteMeta.defaultLang),k={...m,id:rr,lang:sr?.toLowerCase(),group:ir,ts:qe?Math.min(Z,qe):void 0};if(c&&(k.elIndex=lr),z?.startsWith("#")){v.push(k);return}const Ue=z?.startsWith("http")&&!z.includes(`//${location.hostname}/`),ee=Ue?z:x(z);if(!ee){v.push(k);return}if(Ue){v.push({...k,slug:ee});return}const{slug:or,lang:cr}=this.parseReaderSlug(K,ee,z);v.push({...k,slug:or,lang:cr||k.lang})}),B(v,{preferGroup:g})}static async isReaderPage(e,t){const r=e.sel;return t&&!r?!1:!r||!!await P(r,{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 P(t,{lazy:!0,all:!1})}findNeighborChapter({sel:e,basePath:t,titleUrl:r}){const n=p(e);if(!n||n.startsWith("#")||n.startsWith("/#"))return;const s=x(n);if(s&&!(s===location.pathname||r===s||r===`${location.origin}${s}`))return this.parseReaderSlug(t,s,n).slug||void 0}finalizeRawReaderData(e,{prevSlug:t,nextSlug:r}={}){const n=e.title.chapters;if(!n.length){const c=C(t),u=C(r);return!c&&!u?e:{...e,prev:c?{...c,slug:t}:void 0,next:u?{...u,slug:r}:void 0}}let s,i,o,l;for(let c=0;c<n.length&&!(s&&(!t||o)&&!r&&l);c++){const u=n[c];!s&&(e.slug==u.slug||e.chap===u.chap&&(e.vol===u.vol||e.vol===void 0))?(s=u,i=c):!o&&t===u.slug?o=u:!l&&r===u.slug&&(l=u)}return i!==void 0&&(o??(o=n[i+1]),l??(l=n[i-1])),{...e,inferVol:s?.inferVol,prev:o,next:l}}}var It=Object.defineProperty,Pt=(a,e,t)=>e in a?It(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,Ct=(a,e,t)=>(Pt(a,e+"",t),t);class ce extends w{async getRawReleasesData(){const e=Array.from(document.querySelectorAll("script"));for(let t=0;t<e.length;t++){const r=e[t].textContent;if(!r)continue;const n=r.indexOf('{\\"latest\\":');if(n!==-1)try{const s=JSON.parse(r.substring(n).split(',\\"page\\":1')[0].replaceAll("\\","")).latest.data.map(i=>({name:i.name,slug:i.slug,chapters:i.chapters.map(o=>({chap:o.name,slug:o.name+"",at:new Date(o.published_at||o.public_at).getTime()}))}));return this.finalizeRawReleasesData({rawReleases:s})}catch{break}}return super.getRawReleasesData()}}Ct(ce,"specId","asura");function L(){try{return JSON.parse(document.querySelector("pre").textContent)}catch{return}}function Bt(){return Math.random().toString(16).slice(2)}async function Lt({addListener:a,removeListener:e,transform:t,filter:r,handler:n,onTimeout:s,timeout:i,once:o}){return new Promise(l=>{a(g);const c=()=>o===!0&&e(g),u=i?setTimeout(()=>{c(),l(void 0),s?.()},i):void 0;async function g(d,...f){d=t?t(d):d,d!==void 0&&(!r||r(d,...f))&&(c(),l(d),n?.(d,...f),u&&clearTimeout(u))}})}async function Ot(a){return(await Lt({addListener:e=>window.addEventListener("message",e),removeListener:e=>window.removeEventListener("message",e),...a}))?.data}async function jt(a){const{receiverWindow:e,timeout:t,targetOrigin:r,event:n,args:s}=a,i={reqId:Bt(),event:n,args:s};return(e||window)?.postMessage(i,r??"*"),(await Ot({filter:o=>o?.data?.resId===i.reqId,timeout:t??3e4,once:!0}))?.result}const T={isAny:!0};function S(a,...e){return jt({event:"tk:fetchResult",args:{baseUrl:a,segments:e}})}var At=Object.defineProperty,Et=(a,e,t)=>e in a?At(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,Nt=(a,e,t)=>(Et(a,e+"",t),t);class ue extends w{async getRawReaderData(){const e=`https://${location.host}`,[t,r]=await Promise.all([S(e,"api","manga","info"),S(e,"api","read","chapter")]),n=t?.value,s=r?.value;if(!n||!s)return;const i=this.parseReaderSlug(this.siteMeta.readerBase,location.pathname,location.href);if(!i)return;const o=C(s.readChapter?.title);if(o)return this.finalizeRawReaderData({basePath:i.basePath,slug:i.slug,...o,imgs:s.readChapter.pages.map(l=>new URL(l.image,location.origin).href),title:{url:`${e}/manga/${n.id}`,slug:n.id,name:n.title,tags:this.getTagIdsFromNames([n.type].filter(Boolean)),chapters:B(n.chapters.map(l=>({slug:l.id,chap:l.number})),{preferGroup:this.context.preferGroup})}})}async getRawChaptersData(){const e=L();if(e)return{chapters:B(e.chapters.map(t=>({slug:t.id,chap:t.number})),{preferGroup:this.context.preferGroup})}}}Nt(ue,"specId","atsu");var _t=Object.defineProperty,zt=(a,e,t)=>e in a?_t(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,kt=(a,e,t)=>(zt(a,e+"",t),t);class J extends w{parseTitleSlug(e){return{slug:x(e)?.split("/").filter(Boolean)[1]}}}kt(J,"specId","bato");var Wt=Object.defineProperty,qt=(a,e,t)=>e in a?Wt(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,Ut=(a,e,t)=>(qt(a,e+"",t),t);class ge extends w{async getRawReaderData(){const e=await super.getRawReaderData();if(!e)return;const t=window.pages,r=t?.map(n=>n?.image).filter(Boolean);if(!(!Array.isArray(r)||!r.length))return{...e,imgs:r,isWebtoon:t.some(n=>n.height/n.width>2)}}}Ut(ge,"specId","dynasty");var Gt=Object.defineProperty,Ft=(a,e,t)=>e in a?Gt(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,Ht=(a,e,t)=>(Ft(a,e+"",t),t);class pe extends W{async getRawReleasesData(){const e=L();if(e)return this.finalizeRawReleasesData({rawReleases:e.manga.map(t=>({id:t.id?t.id+"":void 0,name:t.title,slug:t.slug,chapters:t.chapters.map(r=>this.praseRawChapter(r))}))})}async getRawSearchData(){const e=L();if(e)return{rawReleases:e.data.map(t=>({id:t.id?t.id+"":void 0,slug:t.slug,name:t.title,img:`${location.origin}/${t.cover}`,chapters:[]}))}}async getRawTitleData(){const{slug:e}=this.parseTitleSlug(location.pathname);if(!e)return;const t=await S(location.origin,"api","backend","api","manga",e);if(!t)return;const r=this.parseRawTitleData(t.value),n=this.context.includeImgBytes&&r.img?await U(r.img):void 0;return{...r,imgBytes:n}}async getRawReaderData(){const{slug:e,titleSlug:t}=this.parseReaderSlug(this.siteMeta.readerBase,location.pathname,location.href);if(!e||!t)return;const[r,n]=await Promise.all([S(location.origin,"api","backend","api","manga",t),S(location.origin,"api","backend","api","chapters","by-number",t,e)]);if(!r||!n)return;const s=await this.parseRawTitleData(r.value),i=n.value;return{slug:e,chap:i.number,basePath:`/${location.pathname.split("/").filter(Boolean).slice(0,-1).join("/")}/`,imgs:i.pages.sort((o,l)=>o.order-l.order).map(o=>`${location.origin}${o.image.startsWith("/")?o.image:`/${o.image}`}`),title:s}}async getRawChaptersData(){const e=L();if(!e)return;const t=this.parseRawTitleData(e);return{chapters:t.chapters,title:{...t,chapters:[]}}}parseRawTitleData(e){return{id:e.id?e.id+"":void 0,url:`${location.origin}/${this.siteMeta.titleBase}/${e.slug}`,slug:e.slug,name:e.title,img:`${location.origin}/${e.cover}`,tags:this.getTagIdsFromNames([e.type,...e.genres.map(t=>t.name)].filter(Boolean)),chapters:e.chapters.map(t=>this.praseRawChapter(t)),hasMoreChapters:e.pagination.hasNextPage}}praseRawChapter(e){return{chap:e.number,slug:e.number+"",ts:new Date(e.createdAt||e.uploadedAt||e.updatedAt).getTime()}}}Ht(pe,"specId","falcon");var Vt=Object.defineProperty,Jt=(a,e,t)=>e in a?Vt(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,Qt=(a,e,t)=>(Jt(a,e+"",t),t);class de extends w{async getRawTitleData(){const e=await super.getRawTitleData();if(e)return{...e,chapters:fe()}}async getRawReaderData(){const e=await super.getRawReaderData();if(!e)return;const t=fe();if(t.length)return{...e,title:{...e.title,img:he(e.title.slug),chapters:t}}}async getRawSearchData(){const e=await super.getRawSearchData();if(e)return{...e,rawReleases:e.rawReleases.map(t=>({...t,img:he(t.slug)}))}}}Qt(de,"specId","kagane");function he(a){return`https://api.${location.host}/api/v1/series/${a}/thumbnail`}function fe(){const a=["initialBooksData","initialChapters"],e=Array.from(document.querySelectorAll("script"));for(let t=0;t<e.length;t++){const r=e[t].textContent;if(r)for(const n of a){const s=r.indexOf(n);if(s===-1)continue;const i=r.slice(s);try{const o=JSON.parse(i.slice(i.indexOf("["),i.indexOf("}]")+2).replaceAll("\\","")),l=[];return o.map(c=>{const u=C(c.name);u&&l.push({...u,slug:c.id,ts:c.created?new Date(c.created).getTime():void 0})}),B(l)}catch{return[]}}}return[]}var Yt=Object.defineProperty,Kt=(a,e,t)=>e in a?Yt(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,Zt=(a,e,t)=>(Kt(a,e+"",t),t);class me extends w{async getRawChaptersData(){const e=L();if(e)return{chapters:e.map(Xt).filter(Boolean)}}}Zt(me,"specId","lua");function Xt(a){if(!a||typeof a.chapter_name!="string")return;const e=C(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 we(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 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,e+"",t),t);class Q extends w{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.spec.title?.sel;if(e&&!await document.querySelector(e))return;const t=this.finalizeNewSiteMeta(this.siteMeta,{titleBase:this.extractBasePath(location.pathname)});this.siteMeta=t??this.siteMeta;const r=await super.getRawTitleData();if(r)return{...r,siteMeta:t}}async getRawReaderData(){const e=this.spec.reader?.sel;if(e&&!await document.querySelector(e))return;const t=ve(this.spec.reader?.title),r=t?this.finalizeNewSiteMeta(this.siteMeta,{titleBase:this.extractBasePath(x(t))}):void 0,n=await super.getRawReaderData();if(n)return{...n,siteMeta:r}}async getRawSearchData(){const e=ve(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,n=document.querySelector(r.sel)??void 0;if(!n)return;const s=x(p(r.url,n));if(s!==void 0)return this.finalizeNewSiteMeta(t,{titleBase:this.extractBasePath(s)})}finalizeNewSiteMeta(e,{titleBase:t}){if(e.titleBase!==t)return{...e,releases:this.siteId?e.releases:null,titleBase:t,readerBase:e.readerBase.replace(e.titleBase,t)}}extractBasePath(e){return we(e,"/").split("/").slice(0,-1).join("/")}}aa(Q,"specId","madara");function ve(a){if(!a)return;const e=a.sel?document.querySelector(a.sel)??void 0:void 0;return p(a.url,e)}var ra=Object.defineProperty,na=(a,e,t)=>e in a?ra(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,sa=(a,e,t)=>(na(a,e+"",t),t);class ye extends w{async getRawTitleData(){const e=await super.getRawTitleData();if(!e)return;const t=await be(this.context.preferGroup),r=new Set;return t.forEach(({lang:n})=>{n&&r.add(n)}),{...e,chapters:t,langs:r.size?Array.from(r):[this.siteMeta.defaultLang||"en"]}}async getRawReaderData(){const e=await super.getRawReaderData();if(!e)return;const t=await be(e.group||this.context.preferGroup),r=t[0]?.lang;return this.finalizeRawReaderData({...e,lang:r,title:{...e.title,chapters:t,langs:r?[r]:void 0}})}}sa(ye,"specId","mangaball");async function be(a){const e=await D(100,50,()=>{try{return ALL_CHAPTERS.length?ALL_CHAPTERS:void 0}catch{return}});if(!e)return[];const t=[];return e.forEach(r=>{r.translations.forEach(n=>{const s=n.volume;t.push({chap:r.number_float,vol:s>0?s:void 0,slug:n.id,lang:n.language,group:n.group?.name,ts:new Date(n.date).getTime()})})}),B(t,{preferGroup:a})}var ia=Object.defineProperty,la=(a,e,t)=>e in a?ia(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,oa=(a,e,t)=>(la(a,e+"",t),t);const ca={a:.1,b:.2,c:.3,d:.4};class Re extends w{parseTitleSlug(e){return{slug:x(e)?.split("/").filter(Boolean)[1]}}async getRawReleasesData(){const e=L()?.data;if(!e)return;const t=[];return e.forEach(({relationships:r,attributes:n,id:s})=>{const i=r.find(({type:g})=>g==="manga"),o=O(n.volume),l=O(n.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:n.externalUrl||s,vol:o,chap:l,lang:n.translatedLanguage,ts:new Date(n.readableAt).valueOf()}]})}),super.finalizeRawReleasesData({rawReleases:t})}async getRawTitleData(){const e=`https://api.${location.host}/manga/`,[t,r]=await Promise.all([S(e,T),S(e,T,"feed")]);if(!t||!r)return;const n=r.value.data?.map?.(l=>{const{attributes:c,id:u}=l;if(typeof c!="object"||typeof u!="string"||!u)return;const{externalUrl:g,title:d,volume:f,chapter:h,translatedLanguage:v}=c;return{slug:g||u,label:d||void 0,vol:O(f),chap:O(h),lang:v||"en",ts:new Date(c.readableAt).valueOf()}}).filter(l=>l?.chap!=null)??[],{data:s}=t.value;if(!s)return;const i=Se({data:s,getTagIdsFromNames:l=>this.getTagIdsFromNames(l)});if(!i)return;const o=this.context.includeImgBytes&&i.img?await U(i.img):void 0;return{...i,imgBytes:o,chapters:B(n,{preferGroup:this.context.preferGroup}),hasMoreChapters:(r.value.total||0)>(r.value.limit||0)}}async getRawReaderData(){const e="https://api.mangadex.org/",[t,r,n]=await Promise.all([S(e,"chapter",T),S(e,"at-home","server",T),S(e,"manga",T,"aggregate")]);if(!t||!r||!n)return;const s=t.value.data,{volume:i,chapter:o,externalUrl:l,translatedLanguage:c}=s.attributes||{},{baseUrl:u,chapter:{data:g,dataSaver:d,hash:f}}=r.value,h=s.relationships?.find?.(m=>m.type==="manga");if(!h)return;const v=Se({data:h,getTagIdsFromNames:m=>this.getTagIdsFromNames(m)});if(!v||typeof n.value.volumes!="object")return;const y=$e(n.value,{preferGroup:this.context.preferGroup})??[];(typeof o!="string"||o==="none")&&!y.length&&y.push({chap:0,slug:s.id});const $=y.findIndex(m=>m.slug===s.id),b=s.relationships?.find?.(m=>m.type==="scanlation_group"),I=u.endsWith("/")?u:u+"/",j=!!localStorage.getItem("md")?.includes?.('"dataSaver":true'),K=`${I}${j?"data-saver":"data"}/`,Z=((j?d:g)??[]).map?.(m=>`${K}${f}/${m}`)??[];return{externalUrl:l,vol:O(i),inferVol:y[$]?.inferVol,chap:O(o)||0,imgs:Z,lang:c,slug:s.id,prev:y[$+1],next:y[$-1],basePath:"/chapter/",group:b?.attributes?.name,groupUrl:b?.attributes?.website,isWebtoon:h?.attributes?.tags?.some(m=>m.attributes.name.en==="Long Strip"),title:{...v,chapters:y}}}async getRawChaptersData(){const e=L();if(!e)return;let t;try{t=$e(e,{preferGroup:this.context.preferGroup})}catch{return}if(t)return{chapters:t,lang:this.context.lang??"en",asc:!1,hasMore:!1,total:t.length}}}oa(Re,"specId","mangadex");function O(a){if(typeof a!="string"||a==="none")return;const e=parseFloat(a);if(e!==e)return;const t=a[a.length-1];return e+(ca[t]??0)}function $e(a,{preferGroup:e}){if(typeof a.volumes!="object")return;const t=Object.values(a.volumes).map(({volume:r,chapters:n})=>{const s=O(r);return Object.values(n).map(({id:i,chapter:o})=>{const l=O(o);if(l!==void 0)return{vol:s,chap:l,slug:i}})}).flat().filter(Boolean).reverse();return B(t,{preferGroup:e})}function Se({data:a,getTagIdsFromNames:e}){const{id:t,attributes:r,relationships:n}=a;if(!t||typeof t!="string"||typeof r!="object")return;const{title:s,availableTranslatedLanguages:i,altTitles:o,tags:l,contentRating:c}=r;if(typeof s!="object"||i&&!Array.isArray(i))return;const u=Object.values(s)[0];if(!u||typeof u!="string")return;const g=ua(),d=(i??[])?.map?.(b=>typeof b=="string"?b:void 0).filter(Boolean)??[],f=d.filter(b=>b&&(!g||g.includes(b))),h=o?.map?.(b=>{const[[,I]=[]]=Object.entries(b);return I}),v=n?.find?.(b=>b.type==="cover_art")?.attributes?.fileName,y=v?`https://mangadex.org/covers/${t}/${v}.256.jpg`:void 0,$=(l||[]).map(b=>b?.attributes?.name?.en).concat(c).filter(Boolean);return{url:`${location.origin}/title/${t}`,slug:t,name:u,altNames:h,langs:f.length>0?f:d.length>0?d:["en"],img:y,tags:e($)}}function ua(){const a=localStorage.getItem("md");if(a)try{const e=JSON.parse(a)?.userPreferences?.filteredLanguages;return e?.length?e:void 0}catch{return}}var ga=Object.defineProperty,pa=(a,e,t)=>e in a?ga(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,da=(a,e,t)=>(pa(a,e+"",t),t);class xe extends w{async getRawReaderData(){if((await P(".current-viewtype",{lazy:!0,all:!1}))?.textContent?.trim().toLowerCase()!=="volume")return await super.getRawReaderData()}async getRawChaptersData(){const e=this.context.lang??"en",t=await P(`.tab-content[data-name="chapter"] a.dropdown-item[data-code="${e.toUpperCase()}"]`,{lazy:!0,all:!1});if(t)return G(t),await P(`.tab-content[data-name="chapter"] li.item[data-number] a[href*="/${e}/"]`,{lazy:!0,all:!1}),await super.getRawChaptersData()}async getRawSearchData(){const e=await super.getRawSearchData();if(!e)return;const t=this.context.lang??"en";return{...e,rawReleases:e.rawReleases.map(r=>({...r,lang:r.lang??t}))}}}da(xe,"specId","mangafire");var ha=Object.defineProperty,fa=(a,e,t)=>e in a?ha(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,ma=(a,e,t)=>(fa(a,e+"",t),t);class De extends w{async getRawReaderData(){const e=await super.getRawReaderData();return e&&{...e,imgs:await this.getImgs()}}parseReaderSlug(e,t){const{slug:r,basePath:n}=super.parseReaderSlug(e,t),s=r.split("/").filter(Boolean),i=s[s.length-1];return{basePath:n,slug:i.startsWith("pg-")?s.slice(0,-1).join("/"):r}}async getImgs(){const e=await D(100,20,()=>window.imgsrcs),t=window.CryptoJS,r=t.enc.Hex.parse("e11adc3949ba59abbe56e057f20f883e"),n={iv:t.enc.Hex.parse("1234567890abcdef1234567890abcdef"),padding:t.pad.ZeroPadding};return t.AES.decrypt(e,r,n).toString(t.enc.Utf8).split(",")}}ma(De,"specId","mangago");var wa=Object.defineProperty,va=(a,e,t)=>e in a?wa(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,ya=(a,e,t)=>(va(a,e+"",t),t);class Me extends w{async getRawTitleData(){const e=`https://backend.${location.host}`,t=await S(e,"chapters-with-ids",T,T),r=await super.getRawTitleData();if(!(!t?.value||!r))return{...r,langs:await ba(),chapters:Y(t.value)}}async getRawChaptersData(){const e=L();if(e)return{chapters:Y(e)}}async getRawReaderData(){const e=`https://backend.${location.host}`,[t,r]=await Promise.all([S(e,"chapters-with-ids",T,T),S(e,"read",T)]);if(!t?.value||!r?.value?.length)return;const n=await super.getRawReaderData();if(!n)return;const s=new URLSearchParams(location.search).get("number")??"0";return{...n,slug:`${n.slug}?number=${s}`,imgs:r.value,title:{...n.title,chapters:Y(t.value)}}}}ya(Me,"specId","mangahaven");async function ba(){const a=document.querySelector('[role="tabpanel"] button');if(!a)return;const e=document.createElement("style");e.innerHTML="[data-radix-popper-content-wrapper] { display: none !important; }",document.head.appendChild(e),a.click();const t=await D(50,10,()=>N('img[src*="/flags/"]|attr:src|pattern:.+/(.+).svg'));return a.click(),setTimeout(()=>document.head.removeChild(e),1e3),t}function Y(a){const e=[];return a?.forEach?.(t=>{const r=+t.chapter;isNaN(r)||!t.id||e.push({chap:r,slug:`${t.id}?number=${t.chapter}`,lang:t.lang?.toLowerCase?.()})}),e}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,e+"",t),t);class Te extends J{}Sa(Te,"specId","mangapill");var xa=Object.defineProperty,Da=(a,e,t)=>e in a?xa(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,Ma=(a,e,t)=>(Da(a,e+"",t),t);class Ie extends w{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]}))}}}Ma(Ie,"specId","mangaplus");var Ta=Object.defineProperty,Ia=(a,e,t)=>e in a?Ta(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,Pa=(a,e,t)=>(Ia(a,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((n,s)=>s.time-n.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:we(location.pathname,"/")},n=e.title,s=document.querySelector(n.sel)??void 0;if(!s)return;const i=x(p(n.url,s));if(i===void 0)return;const o=s.querySelector(n.chapter.sel)??void 0;if(!(!o||x(p(n.chapter.url,o))===void 0))return r.titleBase=this.extractBasePath(i),t.titleIdType===F.id&&(p(n.id,s)||(t.titleIdType=F.name)),this.finalizeNewSiteMeta(t,r)}finalizeNewSiteMeta(e,t){if(this.siteId==="realm")return;const r=Object.keys(t),n={...e};let s=!1;return r.forEach(i=>{const o=t[i];o!==e[i]&&(n[i]=o,s=!0)}),s?n:void 0}}Pa(Pe,"specId","mangastream");var Ca=Object.defineProperty,Ba=(a,e,t)=>e in a?Ca(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,La=(a,e,t)=>(Ba(a,e+"",t),t);class Ce extends w{async getRawReaderData(){const e=await super.getRawReaderData();return e&&{...e,slug:e.slug.split("/").slice(0,-1).join("/")||e.slug.split("/")[0]}}}La(Ce,"specId","mangaworld");var Oa=Object.defineProperty,ja=(a,e,t)=>e in a?Oa(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,Aa=(a,e,t)=>(ja(a,e+"",t),t);class Be extends w{async getRawTitleData(){const e=await super.getRawTitleData();if(e)return{...e,hasMoreChapters:e.chapters.length===50}}}Aa(Be,"specId","mgeko");var Ea=Object.defineProperty,Na=(a,e,t)=>e in a?Ea(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,_a=(a,e,t)=>(Na(a,e+"",t),t);class Le extends W{async getRawReleasesData(){}async getRawSearchData(){}async getRawTitleData(){const e=await Oe();if(!e)return;const t=p("#cover img|[attr:data-src,attr-contain:src]")??e.img;return{...e,img:t,imgBytes:this.context.includeImgBytes&&e.img?await U(e.img):void 0}}async getRawReaderData(){const e=await Oe();if(!e)return;const t=p("#image-container img|[attr:data-src,attr-contain:src]"),r=H(t);if(!r)return;const n=r.pathname.split("/").filter(Boolean).slice(0,-1).join("/"),s=`${r.origin}/${n}/`,i=r.pathname.split("?")[0].split("#")[0].split(".").slice(-1)[0]||"webp";return{chap:0,slug:"1",basePath:e.url.replace(location.origin,"").slice(1),imgs:Array.from({length:e.totalImgs},(o,l)=>`${s}${l+1}.${i}`),title:{name:e.name,slug:e.slug,url:e.url,chapters:[{slug:"1",chap:0}]}}}async getRawChaptersData(){const e=await this.getRawTitleData();if(!e)return;const{chapters:t,...r}=e;return{title:{...r,chapters:[]},chapters:t}}}_a(Le,"specId","nhentai");async function Oe(){const a=await D(100,20,()=>window._gallery);if(!a?.id||!a?.title||!a?.images?.pages)return;const{title:e,images:{pages:t,cover:r},media_id:n}=a;return{name:e.pretty??e.english??e.japanese,slug:a.id+"",url:`${location.origin}/g/${a.id}`,chapters:[{slug:"1",chap:0}],totalImgs:t.length,img:await za(n,r.t)}}async function za(a,e){if(!a||!e)return;const t={j:"jpg",p:"png",g:"gif",w:"webp"}[e];if(!t)return;const r=(await D(10,20,()=>window._n_app))?.options?.thumb_cdn_urls?.[0];if(r)return`https://${r}/galleries/${a}/cover.${t}`}var ka=Object.defineProperty,Wa=(a,e,t)=>e in a?ka(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,qa=(a,e,t)=>(Wa(a,e+"",t),t);class je extends w{async getRawChaptersData(){const e=L();if(e)return{chapters:B(e.map(Ua).filter(Boolean))}}}qa(je,"specId","qi");function Ua(a){if(!(!a||typeof a.number!="number"))return{chap:a.number,slug:typeof a.slug=="string"?a.slug:void 0,ts:typeof a.createdAt=="string"?new Date(a.createdAt).valueOf():void 0}}var Ga=Object.defineProperty,Fa=(a,e,t)=>e in a?Ga(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,Ha=(a,e,t)=>(Fa(a,e+"",t),t);class Ae extends w{finalizeRawReaderData(e,{prevSlug:t,nextSlug:r}={}){if(!e.title.chapters.length){const n=C(t?.split(".").slice(0,-1).join(".")),s=C(r?.split(".").slice(0,-1).join("."));return!n&&!s?e:{...e,prev:n?{...n,slug:t}:void 0,next:s?{...s,slug:r}:void 0}}return super.finalizeRawReaderData(e,{prevSlug:t,nextSlug:r})}}Ha(Ae,"specId","rawkuma");var Va=Object.defineProperty,Ja=(a,e,t)=>e in a?Va(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,Qa=(a,e,t)=>(Ja(a,e+"",t),t);class Ee extends w{async getRawTitleData(){const e=await super.getRawTitleData();if(!e)return;const t=N(".info-detail__row > .genre-btn,.info__right .stats__row:first-child|text")?.map(r=>[r,...r.split(" ")]).flat();return Ne({...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:{...Ne({...e.title,url:t,tags:[]},".episode-list .js-ep-cnt"),hasMoreChapters:!1}}}async getRawChaptersData(){const{rawId:e,skip:t}=this.context,r=1e3,n=t?Math.floor(t/1e3)+1:1;try{const s=await fetch(`/series/${e}/episodes?page=${n}&sort=NEWEST&max_limit=${r}`);return Ya(await s.json())}catch{return}}parseTitleSlug(e){if(!e)return{};const t=e.split("/").filter(Boolean);return{slug:t[1]??t[0]}}}Qa(Ee,"specId","tapas");function Ne(a,e){const t=Ka(e)>20;return{...a,chapters:t?[]:a.chapters,hasMoreChapters:t}}function Ya(a){const e=a?.data?.episodes;if(!Array.isArray(e))return;const t=e.map(n=>({chap:n.pending_scene??n.scene,slug:n.id+"",ts:new Date(n.publish_date)?.valueOf?.()||void 0})),r=a?.data?.pagination;return{chapters:t,total:r?.total??t.length,hasMore:!!r?.has_next}}function Ka(a){return+(document.querySelector(a)?.textContent?.trim().split(" ")[0]||0)}var Za=Object.defineProperty,Xa=(a,e,t)=>e in a?Za(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,er=(a,e,t)=>(Xa(a,e+"",t),t);class _e extends w{async getRawTitleData(){const e=new URLSearchParams(location.search),t=e.get("episode_no"),r=e.get("title_no");if(t||!r)return;const n=await super.getRawTitleData();if(!n)return;const s=location.hostname.startsWith("m."),i=location.pathname.split("/")[1];return{...n,slug:`${n.slug}?title_no=${r}`,id:r,langs:i?[i]:void 0,chapters:s?[]:n.chapters.map(o=>({...o,lang:i})),hasMoreChapters:s||(document.querySelector(".paginate")?.childElementCount??1)>1}}async getRawReaderData(){const e=new URLSearchParams(location.search),t=e.get("episode_no"),r=e.get("title_no"),n=t?+t:void 0;if(!t||!r||typeof n!="number"||isNaN(n))return;const s=document.title.split("|")[1]?.trim();if(!s)return;const i=location.pathname.split("/"),o=`${i.slice(0,4).join("/")}/list?title_no=${r}`,l=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 || a|attr:href|pattern:.+episode_no=(\\d+).*"},{lazy:!1,titleId:r,titleSlug:o}),c=i[1];return{chap:n,lang:c,slug:`${location.pathname}?title_no=${r}&episode_no=${t}`,basePath:"",imgs:await this.getReaderImgs(),isWebtoon:!0,title:{id:r,url:o,slug:o,name:s,langs:[c],chapters:(l??[]).map(u=>({...u,lang:c})),hasMoreChapters:!1}}}async getReaderImgs(){const e=N("#_imageList img|[attr:data-url,attr:src]");return e?.length?e:await D(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 n=H(r);return{basePath:"",slug:n.pathname+n.search}}return{basePath:"",slug:r}}}er(_e,"specId","webtoon");const tr=[ce,ue,J,ge,pe,de,me,Q,ye,Re,xe,De,Me,Te,Ie,Pe,Be,Ce,Le,je,Ae,Ee,_e];function ze(a){const e=tr.find(t=>t.specId===a.spec.id)??w;return new e(a)}async function ar(a){const{spec:e}=a,t=a.siteMeta??e?.meta;if(e&&t){const r=a.type?[a.type]:ke(t,e.generic);if(!r.length)return;const n=ze({...a,spec:e,siteMeta:t});return await E(r.map(s=>n.getRawPageByType(s,r.length>1)))}return await E((a.genericSpecs??[]).map(r=>{if(!r.meta||!r.generic)return[];const n=ke(r.meta,r.generic);if(!n.length)return[];const s=ze({...a,spec:r,siteMeta:r.meta});return n.map(i=>s.getRawPageByType(i,!0))}).flat())}function ke(a,e){if(location.pathname==="/")return[];const{titleBase:t,readerBase:r}=a,n=location.pathname.split("/").filter(Boolean),s=We(n,r),i=We(n,t);if(s&&i)return[R.reader,R.title];const o=[];return!i&&(s!==!1||e)&&o.push(R.reader),!s&&(i!==!1||e)&&o.push(R.title),!o.length&&e?[R.reader,R.title]:o}function We(a,e){if(!e)return;const t=e.split("/").filter(Boolean),r=t.indexOf("{slug}"),n=r===t.length-1,s=!n&&r!==-1;if(n&&(t.pop(),!t.length))return;const i=a.length-t.length;if(s?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===(s?0:1))return!0}A.PageType=R,A.scrape=ar});
|
|
1
|
+
(function(A,E){typeof exports=="object"&&typeof module<"u"?E(exports):typeof define=="function"&&define.amd?define(["exports"],E):(A=typeof globalThis<"u"?globalThis:A||self,E(A._trackkun_={}))})(this,function(A){"use strict";function E(a){let e=!1;return new Promise((t,r)=>{Promise.all(a.map(async n=>{const s=await n;!e&&s&&(e=!0,t(s))})).then(()=>{e||t(void 0)})})}async function D(a,e,t){const r=await t(()=>{a=0});if(r!==void 0)return r;if(!(a<=0))return await new Promise(n=>{setTimeout(async()=>{const s=await D(a-1,e,t);n(s)},e)})}async function P(a,e,t=0){const r=e.root??document.documentElement,n=e.timeoutMs??1e4;return D(e.lazy===!0?n/50:0,50,()=>{const s=e.all===!0?Array.from(r.querySelectorAll(a)):r.querySelector(a)??void 0;return(e.all?!s?.length:!s)?void 0:s})}function G(a){if(a instanceof HTMLOptionElement){const e=a.parentElement instanceof HTMLOptGroupElement?a.parentElement.parentElement:a.parentElement;if(!e||!(e instanceof HTMLSelectElement))return;const t=a.getAttribute("value")||"";if(e.value===t)return;e.value=t,e.dispatchEvent(new Event("change"));return}a instanceof HTMLAnchorElement&&a.addEventListener("click",e=>e.preventDefault(),{once:!0}),a.click(),a.dispatchEvent(new PointerEvent("pointerdown",{bubbles:!0,cancelable:!0,pointerType:"mouse",button:0})),a.dispatchEvent(new MouseEvent("mousedown",{bubbles:!0,cancelable:!0,view:window,button:0}))}const te={text:Je,attr:Qe,"attr-contain":Ye,value:Ke,row:Ze,"bg-image":Xe},Ge={pattern:et,remove:tt,atob:at};function g(a,e){if(a)return ae(a,e,He)}function N(a,e){if(a)return ae(a,e,Ve)}function ae(a,e,t){if(!a)return;const r=a.split("||").map(n=>n.trim()).filter(n=>!!n&&n.includes("|"));for(const n of r){const s=Fe(n);if(!s)continue;const i=t(e??document.documentElement,s);if(i)return i}}function Fe(a){const[e,t,...r]=a.split("|");if(!t)return;const n=t?.startsWith("[")&&t.endsWith("]")?t.substring(1,t.length-1).split(","):[t];return{selector:e||void 0,extractors:n.map(re),transformers:r.map(re)}}function re(a){const e=a.indexOf(":"),t=e!==-1;return{fn:t?a.substring(0,e):a,param:t?a.substring(e+1):""}}function He(a,e){if(!e.selector)return ne(a,e);const t=e.selector.split(",");for(const r of t){const n=Array.from(a.querySelectorAll(r));for(const s of n){const i=ne(s,e);if(i)return i}}}function Ve(a,e){const t=e.selector?Array.from(a.querySelectorAll(e.selector)):[a],r=[];for(const n of t)for(const s of e.extractors){const i=te[s.fn],o=i(n,s.param);if(o){r.push(se(o,e.transformers));break}}if(r.length)return r}function ne(a,e){for(const t of e.extractors){const r=te[t.fn],n=r(a,t.param);if(n)return se(n,e.transformers)}}function se(a,e){let t=a;for(const r of e){const n=Ge[r.fn];n&&(t=n(t,r.param).trim())}return t}function Je(a){return Array.from(a.childNodes).filter(e=>e.nodeType===3).map(e=>_(e.textContent)).filter(Boolean).join(" ").trim()||_(a.textContent)}function Qe(a,e){return _(a.getAttribute(e))}function Ye(a,e){let t=a.getAttribute(e);if(!t){const r=a.getAttributeNames().find(n=>n.includes(e));r&&(t=a.getAttribute(r))}return _(t)}function Ke(a){return a.value}function Ze(a,e){if(!e)return;const t=_(a.textContent)?.toLowerCase(),r=e.toLowerCase();if(!(t!==r&&t!==`${r}:`))return _(a.nextElementSibling?.textContent??a.nextSibling?.textContent)}function Xe(a){const e=getComputedStyle(a).backgroundImage;if(!(!e||!e.startsWith("url(")))return e.slice(5,-2)||void 0}function _(a){if(a)return a?.replace(/(\n|\t)/g," ").trim()||void 0}function et(a,e){if(e)try{return a.replace(new RegExp(e,"i"),"$1")}catch{}return a}function tt(a,e){if(e)try{return a.replaceAll(new RegExp(e,"gi"),"")}catch{}return a}function at(a){try{return window.atob(a)}catch{return a}}var rt=(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))(rt||{}),nt=(a=>(a[a.ok=1]="ok",a[a.hidden=2]="hidden",a[a.deleted=3]="deleted",a))(nt||{}),st=(a=>(a[a.aggregator=0]="aggregator",a[a.scanlator=1]="scanlator",a))(st||{}),it=(a=>(a[a.pending=0]="pending",a[a.completed=1]="completed",a[a.offline=2]="offline",a[a.incompat=3]="incompat",a))(it||{}),F=(a=>(a.id="id",a.name="name",a.slug="slug",a))(F||{}),U=(a=>(a.blank="about:blank",a.title="meta.title",a.reader="meta.reader",a))(U||{});function ie(a=0){return new Promise(e=>setTimeout(e,a))}const lt=/(vol(ume)?|season)(\s*|-|\.)(\d+)/i,ot=/^S([1-9])\s/i,ct=/(ch(ap(t(er)?|\.)?|\.)?|#|episode\.?|capitolo\.?|capitulo\.?|bölüm\.?)(\s*|-)(\d+([_-~,.]\d+)?)/i,ut=/\d+([_-~,.]\d+)?/,gt=/[_-~,]/;function pt(a){const e=a.match(lt);if(e)return{volStr:e[0],volValueStr:e[4]};const t=a.match(ot);return t?{volStr:t[0],volValueStr:t[1]}:{}}function C(a){if(!a)return;if(!isNaN(+a))return{chap:+a};const{volStr:e,volValueStr:t}=pt(a),r=e?a.replace(e,"").trim():a,n=r.match(ct),s=r.match(ut),i=n?.[6],o=i??s?.[0];if(!o)return;const l=+o.replace(gt,".");if(isNaN(l))return;const c=e&&t&&!isNaN(+t)&&a.indexOf(e)<a.indexOf(i?n[0]:s[0])?+t:void 0;return{vol:c===void 0||c<=0?void 0:c,chap:l}}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 n=document.createElement("canvas"),s=n.getContext("2d"),i=Math.max(1,r.naturalWidth/e),o=r.naturalWidth/i,l=r.naturalHeight/i;n.width=o,n.height=l;const c=/iPad|iPhone|iPod/.test(navigator.userAgent);try{s.drawImage(r,0,0,o,l);const u=n.toDataURL(c?"image/jpg":"image/webp",c?.99:.8).split(",").slice(-1)[0];t(u)}catch{t(void 0)}},r.src=a})}async function dt(a,e=240){const t=await ht(a);if(t)return await new Promise(async r=>{const n=q(t,e),s=setTimeout(()=>r(void 0),100),i=await n;clearTimeout(s),r(i)})}async function ht(a){if(a.startsWith("blob:"))return a;try{const e=await fetch(a);if(e.status>=400)return;const t=await e.blob();return URL.createObjectURL(t)}catch{return}}function B(a,e){a.sort((l,c)=>l.vol===void 0||c.vol===void 0?c.chap-l.chap:c.vol-l.vol||c.chap-l.chap);const t={},r={};for(let l=a.length-1;l>=0;l--){const c=a[l],u=c.group??"";t[u]=(t[u]??0)+1;const p=c.lang??"";c.vol!==void 0?r[p]=c.vol:r[p]!==void 0&&(c.inferVol=r[p])}const n=[],s={},i=e?.preferGroup,o=l=>l.lang??"";for(const l of a){const c=o(l),u=s[c],p=n[u];if(!(p&&p.chap===l.chap&&(p.vol===l.vol||p.vol===void 0||l.vol===void 0))){s[c]=n.length,n.push(l);continue}if(!i){p.vol===void 0&&l.vol!=null&&(n[u]=l);continue}p.group!==i&&(l.group==i||p.group&&!l.group||t[l.group??""]>t[p.group??""])&&(n[u]=l)}return n}const ft=[{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 le(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 n=new Date(t);if(n instanceof Date){const c=n.valueOf();if(!isNaN(c))return n.getHours()===0&&n.getMinutes()===0?Math.min(r,c+432e5):c}const s=ft.find(c=>e&&c.locales[e]&&t.indexOf(c.locales[e])!==-1?!0:t.indexOf(c.locales.en)!==-1);if(!s)return;const i=t.split(" ").filter(Boolean),o=oe(i)??(e==="en"?oe(i,["a","an"]):void 0);if(!o)return;const l=r-o*s.seconds*1e3;return l>0?l:void 0}function oe(a,e){for(let t=0;t<a.length;t++){const r=a[t];if(e?.includes(r))return 1;const n=+r;if(n)return n<0?void 0:n}}function mt(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 wt(a,{titleSlug:e,titleId:t,lang:r}){if(!a)return"/";let n=a;return e&&(n=n.replace("{titleSlug}",e)),t&&(n=n.replace("{titleId}",t)),r&&(n=n.replace("{lang}",r)),n.endsWith("/")||(n+="/"),n.startsWith("/")||(n="/"+n),n}function H(a){if(!a)return;let e=a;e.startsWith("//")&&(e=`https:${e}`);try{return new URL(e)}catch{return}}function x(a){if(!(!a||typeof a!="string"))return a.includes("//")?H(a)?.pathname:a}function vt(a,e){const t=[...e],r=[];let n=!1,s=0;const i=Math.min(a.length,100);for(let l=0;l<i;l++){if(s>=10/2){const f=10-r.length;if(f>0){const h=l+f<=a.length?a.slice(l,l+f):t.slice(0,f);r.push(...h)}break}const c=a[l],u=c.id!==void 0,p=t.findIndex(f=>u&&f.id===c.id||f.slug===c.slug||f.name==c.name),d=p===-1?void 0:t.splice(p,1)[0];!d||d.chapters[0]?.chap!==c.chapters[0]?.chap?(n=!0,r.push({...c,changed:!0})):(s++,r.push(c))}if(!n)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 yt(a,e){const t={};return a.forEach(r=>{const n=r.chapters.reduce((s,i)=>{const o=i.lang||e||"";return s[o]||(s[o]=[]),s[o].push(i),s},{});Object.entries(n).forEach(([s,i])=>{const o=`${r.slug}:${s}`;t[o]?(t[o].chapters.push(...i),B(t[o].chapters)):t[o]={...r,lang:s===""?void 0:s,chapters:i}})}),Object.values(t)}var R=(a=>(a.title="title",a.reader="reader",a.releases="releases",a.chapters="chapters",a.search="search",a))(R||{}),bt=Object.defineProperty,Rt=(a,e,t)=>e in a?bt(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,M=(a,e,t)=>(Rt(a,typeof e!="symbol"?e+"":e,t),t);class W{constructor(e){M(this,"headless"),M(this,"siteId"),M(this,"spec"),M(this,"siteMeta"),M(this,"tags"),M(this,"context"),M(this,"methodsMap",{[R.title]:()=>this.getRawTitleData(),[R.reader]:()=>this.getRawReaderData(),[R.releases]:()=>this.getRawReleasesData(),[R.search]:()=>this.getRawSearchData(),[R.chapters]:()=>this.getRawChaptersData()}),M(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 getRawPageByType(e,t=!1){const r=await this.methodsMap[e](),n=!r&&(e===R.title||e===R.reader)&&await St(this.spec);if(t&&!r&&!n)return;const s=location.origin+location.pathname;return{type:e,is404:n,specId:this.spec.id,siteName:Dt(this.spec.name),favUrl:Mt(),htmlLang:Tt(),url:s,data:r,spec:this.spec,context:this.context}}parseReaderSlug(e,t,r){const n=e.includes("{"),s=!this.siteId;let i=t;if(i[0]!=="/"&&(i.includes("/")||s&&!n))try{i=new URL(t,location.href).pathname}catch{}if(i.endsWith("/")&&(i=i.slice(0,-1)),e.startsWith("/")||(e="/"+e),e.endsWith("/")||(e=e+"/"),n){const o=e.split("/").filter(Boolean),l=i.split("/").filter(Boolean);if(o.length<l.length){const c=l[o.indexOf("{lang}")]?.toLowerCase(),u=l[o.indexOf("{titleId}")],p=l[o.indexOf("{titleSlug}")],d=e.replace("{lang}",c).replace("{titleId}",u).replace("{titleSlug}",p);if(s)return{basePath:"",slug:i,lang:c,titleId:u,titleSlug:p};if(i.startsWith(d))return{basePath:d,slug:i.replace(d,""),lang:c,titleId:u,titleSlug:p}}}else if(!s&&i.startsWith(e))return{basePath:e,slug:i.replace(e,"")};return{basePath:"",slug:i}}parseTitleSlug(e){if(typeof e!="string")return{};const t=x(e),r=t?.split("/").filter(Boolean);if(!r?.length)return{};const n=this.siteMeta.titleBase.split("/").filter(Boolean),s=n.indexOf("{slug}");return(s===-1?r.length-n.length>=1:r.length===n.length)?{id:r[n.indexOf("{id}")],slug:this.siteId?s===-1?r.slice(n.length).join("/"):r[s]:t}:{slug:t}}finalizeRawReleasesData(e){const t=this.spec.releases?.title?.lang?this.siteMeta.defaultLang:void 0,r=yt(e.rawReleases,t);if(r.length)return this.context.oldRawReleases?vt(r,this.context.oldRawReleases):{rawReleases:r,hasMore:!0}}getTagIdsFromNames(e){if(!e?.length)return;const t=this.normalizedTagsMap??(this.normalizedTagsMap=$t(this.tags)),r=e.map(n=>t[V(n)]).filter(Boolean);return r.length===0?void 0:Array.from(new Set(r)).sort((n,s)=>n-s)}}M(W,"specId"),M(W,"siteId");function $t(a){const e={};return a.forEach(({id:t,name:r,altNames:n})=>{e[V(r)]=t,n&&n.forEach(s=>{e[V(s)]=t})}),e}function V(a){const e=a.toLowerCase().replaceAll(/[^a-z0-9\s]/gi,"").trim().replaceAll(/\s+/g," ");return e[e.length-1]==="s"?e.substring(0,e.length-1):e}async function St(a){return xt()===404||a[404]&&await P(a[404],{lazy:!0,timeoutMs:5e3})?!0:document.title.toLowerCase().includes("not found")}function xt(){try{return window.performance.getEntries().find(a=>a.entryType==="navigation")?.responseStatus}catch{return}}function Dt(a){return(a&&g(a))??g('meta[property="og:site_name"]|attr:content')}function Mt(){return g('link[rel="icon"][sizes="32x32"],link[rel="icon"][sizes="192x192"],link[rel="apple-touch-icon"]|attr:href')}function Tt(){return g("html|attr:lang")||"en"}class w extends W{async getRawReleasesData(){if(!this.spec?.releases?.title)return;const{chapter:e,...t}=this.spec.releases.title,r=await P(t.sel,{lazy:!0,all:!0});if(!r?.length)return;const n=Date.now(),s=r.slice(0,100).map(o=>{const l=g(t.url,o),c=x(l),u=g(t.name,o),p=g(t.at,o);if(!c||!u)return;const d=le(p,this.siteMeta.defaultLang);return{titleEl:o,id:g(t.id,o),path:c,name:u,lang:g(t.lang,o)?.toLowerCase(),at:d?Math.min(d,n):void 0}}).filter(Boolean);if(!s.length)return;const i=[];return await Promise.all(s.map(async o=>{const{path:l,titleEl:c,lang:u,at:p,...d}=o,{id:f,slug:h}=this.parseTitleSlug(l);if(!h)return;const v=d.id||f,y=await this.getChapters(e,{root:c,titleId:v,titleSlug:h,lang:u})??[];y.length&&i.push({slug:h,chapters:u||p?y.map($=>({...$,elIndex:void 0,lang:$.lang??u,ts:$.ts??p})):y,...d,id:v})})),this.finalizeRawReleasesData({rawReleases:i})}getRawTitleData(){return this.getTitleData(this.spec.title)}async getTitleData(e){if(!e||(e.sel||e.lazy)&&!await P(e.sel??e.name,{lazy:!!e.lazy}))return;const{id:t,slug:r}=this.parseTitleSlug(location.pathname);if(!r)return;const n=t||g(e.id),s=await this.getChapters(e.chapter,{lazy:!0,titleId:n,titleSlug:r,preferGroup:this.context.preferGroup})??[],i=g(e.name);if(!i)return;const o=await this.getValidImgSrc(e.img,i),l=o&&this.context.includeImgBytes?await dt(o):void 0,c=this.getFirstChapterUrl(),u=e.firstBtn,p=N(e.tags)?.map(h=>h.split(",")).flat().map(h=>h.trim()).filter(Boolean),d=g(e.type),f=N(e.langs)?.map(h=>h.toLowerCase());return{id:n||g(e.id),url:location.origin+location.pathname,slug:r,name:i,langs:f?.length?f:e.langs&&this.siteMeta.defaultLang?[this.siteMeta.defaultLang]:void 0,tags:this.getTagIdsFromNames([...p??[],...d?[d]:[]]),chapters:s,hasMoreChapters:e.hasMore?!!document.querySelector(e.hasMore):void 0,img:o,imgBytes:l,firstUrl:c,firstBtn:!c&&u&&document.querySelector(u)?u:void 0,trackers:this.getTrackersMap(e.trackers)}}getTrackersMap(e){if(!e)return;const t=g(e.mal),r=g(e.anl);if(!t||!r)return;const n={};return t&&(n.mal=t),r&&(n.anl=r),n}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,t){return D(33,30,()=>{const r=g(e)||g(`img[alt="${t.replaceAll('"',"")}"]|[attr:data-src,attr-contain:src]`);return!r||r.startsWith("data:")?void 0:document.querySelector(`img[srcset*="${r}"]`)?r.split(" ")[0]:r})}getRawReaderTitleData(e){const t=this.spec.reader?.title;if(!t)return;const r=t.sel?document.querySelector(t.sel)??void 0:void 0,n=g(t.name,r);if(!n)return;const s=mt(g(t.img,r));if(e?.slug){let c=this.siteMeta.titleBase;if(e?.id&&(c=c.replace("{id}",e.id)),!c.includes("{"))return c=c.includes("{slug}")?c.replace("{slug}",e.slug):`${c}/${e.slug}`,this.siteMeta.trailing&&!c.endsWith("/")&&(c+="/"),{name:n,img:s,url:new URL(c,location.origin).href,slug:e.slug,id:e.id||g(t.id)}}const i=g(t.url,r),{slug:o,id:l}=this.parseTitleSlug(i);if(!(!n||!i||!o))return{name:n,img:s,url:new URL(i,location.origin).href,slug:o,id:l||g(t.id)||e?.id}}async getRawReaderData(){const{spec:e,siteMeta:t}=this;if(!e?.reader||!await w.isReaderPage(e.reader,!!e.generic))return;const r=e.reader.content;if(!(!r||await w.verifyImgsCotainer(r)))return;const n=this.parseReaderSlug(t.readerBase,location.pathname,location.href),{slug:s,basePath:i,lang:o}=n,l=this.getRawReaderTitleData({id:n.titleId,slug:n.titleSlug});if(!l)return;const c=g(e.reader.group),{id:u,slug:p}=l,d=e.reader?.chapter,f=!!this.context.disableLazyChapters,h=!!this.context.includeHiddenChapters,v=await this.getChapters(d,{titleId:u,titleSlug:p,lang:o,lazy:h||!f,includeHiddenChapters:h,timeoutMs:h?3e3:29e3,includeIndex:!0,basePath:i,preferGroup:c||this.context.preferGroup})??[],y=g(e.reader.label)?.toLowerCase().replace(l.name.toLowerCase(),"");if(!y)return;const{vol:$,chap:b=0}=C(y)||{},I=this.findNeighborChapter({sel:e.reader.prev,basePath:i,titleUrl:l.url}),j=this.findNeighborChapter({sel:e.reader.next,basePath:i,titleUrl:l.url});return this.finalizeRawReaderData({vol:$,chap:b,lang:o??g(e.reader.lang)?.toLowerCase()??(e.reader.lang?this.siteMeta.defaultLang:void 0),slug:s,basePath:i,group:c??g(e.reader.group),imgs:N(e.reader.imgs),title:{id:u||g(this.spec.reader?.title.id),url:l.url,slug:p,name:l.name,langs:o?[o]:void 0,img:l.img,chapters:v,hasMoreChapters:!v.length&&!h&&!!this.context.disableLazyChapters&&!!d?.label}},{prevSlug:I,nextSlug:j})}async getRawChaptersData(){const e=this.siteMeta.chapters;if(e===U.blank)return;const t=e===U.reader,r=!e||e===U.title,n=t?(await this.getRawReaderData())?.title:r?await this.getRawTitleData():void 0,s=this.spec.chapters?.chapter,i=s?await this.getChapters(s,{titleId:n?.id,titleSlug:n?.slug,lazy:this.spec.chapters?.lazy,includeHiddenChapters:!0,lang:this.context.lang,preferGroup:this.context.preferGroup}):n?.chapters;if(!i)return;const{lang:o}=this.context,l=o?i.filter(c=>!c.lang||c.lang===o):i;return{chapters:l,title:n?{...n,chapters:[]}:await this.getTitleData(this.spec.chapters?.title),hasMore:!1,asc:!1,total:l.length}}async getRawSearchData(){const e=this.spec.search,t=this.context.lang;if(!e)return;e.delay&&await ie(e.delay);const r=e.title,{chapter:n}=r,s=[],i=e.lazy?e.empty||e.loading?550:100:1,o=await D(i,50,()=>{const l=Array.from(document.querySelectorAll(r.sel));if(l.length||e.empty&&document.querySelector(e.empty)||e.loading&&!document.querySelector(e.loading))return l});if(o)return await Promise.all(o.map(async l=>{const c=g(r.url,l),u=x(c),p=g(r.name,l),{slug:d,id:f}=this.parseTitleSlug(u);if(!u||!p||!d)return;const h=g(r.lang,l);h&&t&&h!==t||s.push({id:f||g(r.id,l),slug:d,name:p,img:g(r.img??"img|[attr:data-src,attr-contain:src]",l),lang:h,chapters:await this.getChapters(n,{root:l,titleId:f,titleSlug:d})??[]})})),{rawReleases:s}}async getChapters(e,{root:t,titleId:r,titleSlug:n,lang:s,includeHiddenChapters:i=!1,lazy:o=!0,timeoutMs:l,includeIndex:c,basePath:u,preferGroup:p}){const d=e?.sel;if(!d||!e.label)return;const f=d.includes("{titleSlug}")?n?d.replace("{titleSlug}",n):void 0:d;if(!f)return;let h;if(e.trigger&&(!i||(h=await P(e.trigger,{timeoutMs:5e3,lazy:!0}),!h)))return;const v=[],y=await D(l??(o?200:1),50,async()=>{h&&(G(h),await ie(50));const m=Array.from((t??document.documentElement)?.querySelectorAll(f));if(m.length)return m}),$=(y??[]).map((m,X)=>({id:g(e.id,m),label:g(e.label,m),url:g(e.url,m),at:g(e.at,m),lang:g(e.lang,m),group:g(e.group,m),elIndex:X})),b=(e.dismiss?(t??document.body).querySelector(e.dismiss):void 0)??h;if(b&&G(b),!y?.length)return[];const I=$.map(({label:m})=>C(m)),j=I[1]?.chap;!I[0]&&(j===void 0||j<=1)&&(I[0]={chap:0});const K=u??wt(this.siteMeta.readerBase,{titleId:r,titleSlug:n,lang:s}),Z=Date.now();return I.forEach((m,X)=>{if(!m)return;const{id:rr,url:z,at:nr,lang:sr,group:ir,elIndex:lr}=$[X],Ue=le(nr,this.siteMeta.defaultLang),k={...m,id:rr,lang:sr?.toLowerCase(),group:ir,ts:Ue?Math.min(Z,Ue):void 0};if(c&&(k.elIndex=lr),z?.startsWith("#")){v.push(k);return}const qe=z?.startsWith("http")&&!z.includes(`//${location.hostname}/`),ee=qe?z:x(z);if(!ee){v.push(k);return}if(qe){v.push({...k,slug:ee});return}const{slug:or,lang:cr}=this.parseReaderSlug(K,ee,z);v.push({...k,slug:or,lang:cr||k.lang})}),B(v,{preferGroup:p})}static async isReaderPage(e,t){const r=e.sel;return t&&!r?!1:!r||!!await P(r,{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 P(t,{lazy:!0,all:!1})}findNeighborChapter({sel:e,basePath:t,titleUrl:r}){const n=g(e);if(!n||n.startsWith("#")||n.startsWith("/#"))return;const s=x(n);if(s&&!(s===location.pathname||r===s||r===`${location.origin}${s}`))return this.parseReaderSlug(t,s,n).slug||void 0}finalizeRawReaderData(e,{prevSlug:t,nextSlug:r}={}){const n=e.title.chapters;if(!n.length){const c=C(t),u=C(r);return!c&&!u?e:{...e,prev:c?{...c,slug:t}:void 0,next:u?{...u,slug:r}:void 0}}let s,i,o,l;for(let c=0;c<n.length&&!(s&&(!t||o)&&!r&&l);c++){const u=n[c];!s&&(e.slug==u.slug||e.chap===u.chap&&(e.vol===u.vol||e.vol===void 0))?(s=u,i=c):!o&&t===u.slug?o=u:!l&&r===u.slug&&(l=u)}return i!==void 0&&(o??(o=n[i+1]),l??(l=n[i-1])),{...e,inferVol:s?.inferVol,prev:o,next:l}}}var It=Object.defineProperty,Pt=(a,e,t)=>e in a?It(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,Ct=(a,e,t)=>(Pt(a,e+"",t),t);class ce extends w{async getRawReleasesData(){const e=Array.from(document.querySelectorAll("script"));for(let t=0;t<e.length;t++){const r=e[t].textContent;if(!r)continue;const n=r.indexOf('{\\"latest\\":');if(n!==-1)try{const s=JSON.parse(r.substring(n).split(',\\"page\\":1')[0].replaceAll("\\","")).latest.data.map(i=>({name:i.name,slug:i.slug,chapters:i.chapters.map(o=>({chap:o.name,slug:o.name+"",at:new Date(o.published_at||o.public_at).getTime()}))}));return this.finalizeRawReleasesData({rawReleases:s})}catch{break}}return super.getRawReleasesData()}}Ct(ce,"specId","asura");function L(){try{return JSON.parse(document.querySelector("pre").textContent)}catch{return}}function Bt(){return Math.random().toString(16).slice(2)}async function Lt({addListener:a,removeListener:e,transform:t,filter:r,handler:n,onTimeout:s,timeout:i,once:o}){return new Promise(l=>{a(p);const c=()=>o===!0&&e(p),u=i?setTimeout(()=>{c(),l(void 0),s?.()},i):void 0;async function p(d,...f){d=t?t(d):d,d!==void 0&&(!r||r(d,...f))&&(c(),l(d),n?.(d,...f),u&&clearTimeout(u))}})}async function Ot(a){return(await Lt({addListener:e=>window.addEventListener("message",e),removeListener:e=>window.removeEventListener("message",e),...a}))?.data}async function jt(a){const{receiverWindow:e,timeout:t,targetOrigin:r,event:n,args:s}=a,i={reqId:Bt(),event:n,args:s};return(e||window)?.postMessage(i,r??"*"),(await Ot({filter:o=>o?.data?.resId===i.reqId,timeout:t??3e4,once:!0}))?.result}const T={isAny:!0};function S(a,...e){return jt({event:"tk:fetchResult",args:{baseUrl:a,segments:e}})}var At=Object.defineProperty,Et=(a,e,t)=>e in a?At(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,Nt=(a,e,t)=>(Et(a,e+"",t),t);class ue extends w{async getRawReaderData(){const e=`https://${location.host}`,[t,r]=await Promise.all([S(e,"api","manga","info"),S(e,"api","read","chapter")]),n=t?.value,s=r?.value;if(!n||!s)return;const i=this.parseReaderSlug(this.siteMeta.readerBase,location.pathname,location.href);if(!i)return;const o=C(s.readChapter?.title);if(o)return this.finalizeRawReaderData({basePath:i.basePath,slug:i.slug,...o,imgs:s.readChapter.pages.map(l=>new URL(l.image,location.origin).href),title:{url:`${e}/manga/${n.id}`,slug:n.id,name:n.title,tags:this.getTagIdsFromNames([n.type].filter(Boolean)),chapters:B(n.chapters.map(l=>({slug:l.id,chap:l.number})),{preferGroup:this.context.preferGroup})}})}async getRawChaptersData(){const e=L();if(e)return{chapters:B(e.chapters.map(t=>({slug:t.id,chap:t.number})),{preferGroup:this.context.preferGroup})}}}Nt(ue,"specId","atsu");var _t=Object.defineProperty,zt=(a,e,t)=>e in a?_t(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,kt=(a,e,t)=>(zt(a,e+"",t),t);class J extends w{parseTitleSlug(e){return{slug:x(e)?.split("/").filter(Boolean)[1]}}}kt(J,"specId","bato");var Wt=Object.defineProperty,Ut=(a,e,t)=>e in a?Wt(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,qt=(a,e,t)=>(Ut(a,e+"",t),t);class ge extends w{async getRawReaderData(){const e=await super.getRawReaderData();if(!e)return;const t=window.pages,r=t?.map(n=>n?.image).filter(Boolean);if(!(!Array.isArray(r)||!r.length))return{...e,imgs:r,isWebtoon:t.some(n=>n.height/n.width>2)}}}qt(ge,"specId","dynasty");var Gt=Object.defineProperty,Ft=(a,e,t)=>e in a?Gt(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,Ht=(a,e,t)=>(Ft(a,e+"",t),t);class pe extends W{async getRawReleasesData(){const e=L();if(e)return this.finalizeRawReleasesData({rawReleases:e.manga.map(t=>({id:t.id?t.id+"":void 0,name:t.title,slug:t.slug,chapters:t.chapters.map(r=>this.praseRawChapter(r))}))})}async getRawSearchData(){const e=L();if(e)return{rawReleases:e.data.map(t=>({id:t.id?t.id+"":void 0,slug:t.slug,name:t.title,img:`${location.origin}/${t.cover}`,chapters:[]}))}}async getRawTitleData(){const{slug:e}=this.parseTitleSlug(location.pathname);if(!e)return;const t=await S(location.origin,"api","backend","api","manga",e);if(!t)return;const r=this.parseRawTitleData(t.value),n=this.context.includeImgBytes&&r.img?await q(r.img):void 0;return{...r,imgBytes:n}}async getRawReaderData(){const{slug:e,titleSlug:t}=this.parseReaderSlug(this.siteMeta.readerBase,location.pathname,location.href);if(!e||!t)return;const[r,n]=await Promise.all([S(location.origin,"api","backend","api","manga",t),S(location.origin,"api","backend","api","chapters","by-number",t,e)]);if(!r||!n)return;const s=await this.parseRawTitleData(r.value),i=n.value;return{slug:e,chap:i.number,basePath:`/${location.pathname.split("/").filter(Boolean).slice(0,-1).join("/")}/`,imgs:i.pages.sort((o,l)=>o.order-l.order).map(o=>`${location.origin}${o.image.startsWith("/")?o.image:`/${o.image}`}`),title:s}}async getRawChaptersData(){const e=L();if(!e)return;const t=this.parseRawTitleData(e);return{chapters:t.chapters,title:{...t,chapters:[]}}}parseRawTitleData(e){return{id:e.id?e.id+"":void 0,url:`${location.origin}/${this.siteMeta.titleBase}/${e.slug}`,slug:e.slug,name:e.title,img:`${location.origin}/${e.cover}`,tags:this.getTagIdsFromNames([e.type,...e.genres.map(t=>t.name)].filter(Boolean)),chapters:e.chapters.map(t=>this.praseRawChapter(t)),hasMoreChapters:e.pagination.hasNextPage}}praseRawChapter(e){return{chap:e.number,slug:e.number+"",ts:new Date(e.createdAt||e.uploadedAt||e.updatedAt).getTime()}}}Ht(pe,"specId","falcon");var Vt=Object.defineProperty,Jt=(a,e,t)=>e in a?Vt(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,Qt=(a,e,t)=>(Jt(a,e+"",t),t);class de extends w{async getRawTitleData(){const e=await super.getRawTitleData();if(e)return{...e,chapters:fe()}}async getRawReaderData(){const e=await super.getRawReaderData();if(!e)return;const t=fe();if(t.length)return{...e,title:{...e.title,img:he(e.title.slug),chapters:t}}}async getRawSearchData(){const e=await super.getRawSearchData();if(e)return{...e,rawReleases:e.rawReleases.map(t=>({...t,img:he(t.slug)}))}}}Qt(de,"specId","kagane");function he(a){return`https://api.${location.host}/api/v1/series/${a}/thumbnail`}function fe(){const a=["initialBooksData","initialChapters"],e=Array.from(document.querySelectorAll("script"));for(let t=0;t<e.length;t++){const r=e[t].textContent;if(r)for(const n of a){const s=r.indexOf(n);if(s===-1)continue;const i=r.slice(s);try{const o=JSON.parse(i.slice(i.indexOf("["),i.indexOf("}]")+2).replaceAll("\\","")),l=[];return o.map(c=>{const u=C(c.name);u&&l.push({...u,slug:c.id,ts:c.created?new Date(c.created).getTime():void 0})}),B(l)}catch{return[]}}}return[]}var Yt=Object.defineProperty,Kt=(a,e,t)=>e in a?Yt(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,Zt=(a,e,t)=>(Kt(a,e+"",t),t);class me extends w{async getRawChaptersData(){const e=L();if(e)return{chapters:e.map(Xt).filter(Boolean)}}}Zt(me,"specId","lua");function Xt(a){if(!a||typeof a.chapter_name!="string")return;const e=C(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 we(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 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,e+"",t),t);class Q extends w{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.spec.title?.sel;if(e&&!await document.querySelector(e))return;const t=this.finalizeNewSiteMeta(this.siteMeta,{titleBase:this.extractBasePath(location.pathname)});this.siteMeta=t??this.siteMeta;const r=await super.getRawTitleData();if(r)return{...r,siteMeta:t}}async getRawReaderData(){const e=this.spec.reader?.sel;if(e&&!await document.querySelector(e))return;const t=ve(this.spec.reader?.title),r=t?this.finalizeNewSiteMeta(this.siteMeta,{titleBase:this.extractBasePath(x(t))}):void 0,n=await super.getRawReaderData();if(n)return{...n,siteMeta:r}}async getRawSearchData(){const e=ve(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,n=document.querySelector(r.sel)??void 0;if(!n)return;const s=x(g(r.url,n));if(s!==void 0)return this.finalizeNewSiteMeta(t,{titleBase:this.extractBasePath(s)})}finalizeNewSiteMeta(e,{titleBase:t}){if(e.titleBase!==t)return{...e,releases:this.siteId?e.releases:null,titleBase:t,readerBase:e.readerBase.replace(e.titleBase,t)}}extractBasePath(e){return we(e,"/").split("/").slice(0,-1).join("/")}}aa(Q,"specId","madara");function ve(a){if(!a)return;const e=a.sel?document.querySelector(a.sel)??void 0:void 0;return g(a.url,e)}var ra=Object.defineProperty,na=(a,e,t)=>e in a?ra(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,sa=(a,e,t)=>(na(a,e+"",t),t);class ye extends w{async getRawTitleData(){const e=await super.getRawTitleData();if(!e)return;const t=await be(this.context.preferGroup),r=new Set;return t.forEach(({lang:n})=>{n&&r.add(n)}),{...e,chapters:t,langs:r.size?Array.from(r):[this.siteMeta.defaultLang||"en"]}}async getRawReaderData(){const e=await super.getRawReaderData();if(!e)return;const t=await be(e.group||this.context.preferGroup),r=t[0]?.lang;return this.finalizeRawReaderData({...e,lang:r,title:{...e.title,chapters:t,langs:r?[r]:void 0}})}}sa(ye,"specId","mangaball");async function be(a){const e=await D(100,50,()=>{try{return ALL_CHAPTERS.length?ALL_CHAPTERS:void 0}catch{return}});if(!e)return[];const t=[];return e.forEach(r=>{r.translations.forEach(n=>{const s=n.volume;t.push({chap:r.number_float,vol:s>0?s:void 0,slug:n.id,lang:n.language,group:n.group?.name,ts:new Date(n.date).getTime()})})}),B(t,{preferGroup:a})}var ia=Object.defineProperty,la=(a,e,t)=>e in a?ia(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,oa=(a,e,t)=>(la(a,e+"",t),t);const ca={a:.1,b:.2,c:.3,d:.4};class Re extends w{parseTitleSlug(e){return{slug:x(e)?.split("/").filter(Boolean)[1]}}async getRawReleasesData(){const e=L()?.data;if(!e)return;const t=[];return e.forEach(({relationships:r,attributes:n,id:s})=>{const i=r.find(({type:p})=>p==="manga"),o=O(n.volume),l=O(n.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:n.externalUrl||s,vol:o,chap:l,lang:n.translatedLanguage,ts:new Date(n.readableAt).valueOf()}]})}),super.finalizeRawReleasesData({rawReleases:t})}async getRawTitleData(){const e=`https://api.${location.host}/manga/`,[t,r]=await Promise.all([S(e,T),S(e,T,"feed")]);if(!t||!r)return;const n=r.value.data?.map?.(l=>{const{attributes:c,id:u}=l;if(typeof c!="object"||typeof u!="string"||!u)return;const{externalUrl:p,title:d,volume:f,chapter:h,translatedLanguage:v}=c;return{slug:p||u,label:d||void 0,vol:O(f),chap:O(h),lang:v||"en",ts:new Date(c.readableAt).valueOf()}}).filter(l=>l?.chap!=null)??[],{data:s}=t.value;if(!s)return;const i=Se({data:s,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:B(n,{preferGroup:this.context.preferGroup}),hasMoreChapters:(r.value.total||0)>(r.value.limit||0)}}async getRawReaderData(){const e="https://api.mangadex.org/",[t,r,n]=await Promise.all([S(e,"chapter",T),S(e,"at-home","server",T),S(e,"manga",T,"aggregate")]);if(!t||!r||!n)return;const s=t.value.data,{volume:i,chapter:o,externalUrl:l,translatedLanguage:c}=s.attributes||{},{baseUrl:u,chapter:{data:p,dataSaver:d,hash:f}}=r.value,h=s.relationships?.find?.(m=>m.type==="manga");if(!h)return;const v=Se({data:h,getTagIdsFromNames:m=>this.getTagIdsFromNames(m)});if(!v||typeof n.value.volumes!="object")return;const y=$e(n.value,{preferGroup:this.context.preferGroup})??[];(typeof o!="string"||o==="none")&&!y.length&&y.push({chap:0,slug:s.id});const $=y.findIndex(m=>m.slug===s.id),b=s.relationships?.find?.(m=>m.type==="scanlation_group"),I=u.endsWith("/")?u:u+"/",j=!!localStorage.getItem("md")?.includes?.('"dataSaver":true'),K=`${I}${j?"data-saver":"data"}/`,Z=((j?d:p)??[]).map?.(m=>`${K}${f}/${m}`)??[];return{externalUrl:l,vol:O(i),inferVol:y[$]?.inferVol,chap:O(o)||0,imgs:Z,lang:c,slug:s.id,prev:y[$+1],next:y[$-1],basePath:"/chapter/",group:b?.attributes?.name,groupUrl:b?.attributes?.website,isWebtoon:h?.attributes?.tags?.some(m=>m.attributes.name.en==="Long Strip"),title:{...v,chapters:y}}}async getRawChaptersData(){const e=L();if(!e)return;let t;try{t=$e(e,{preferGroup:this.context.preferGroup})}catch{return}if(t)return{chapters:t,lang:this.context.lang??"en",asc:!1,hasMore:!1,total:t.length}}}oa(Re,"specId","mangadex");function O(a){if(typeof a!="string"||a==="none")return;const e=parseFloat(a);if(e!==e)return;const t=a[a.length-1];return e+(ca[t]??0)}function $e(a,{preferGroup:e}){if(typeof a.volumes!="object")return;const t=Object.values(a.volumes).map(({volume:r,chapters:n})=>{const s=O(r);return Object.values(n).map(({id:i,chapter:o})=>{const l=O(o);if(l!==void 0)return{vol:s,chap:l,slug:i}})}).flat().filter(Boolean).reverse();return B(t,{preferGroup:e})}function Se({data:a,getTagIdsFromNames:e}){const{id:t,attributes:r,relationships:n}=a;if(!t||typeof t!="string"||typeof r!="object")return;const{title:s,availableTranslatedLanguages:i,altTitles:o,tags:l,contentRating:c}=r;if(typeof s!="object"||i&&!Array.isArray(i))return;const u=Object.values(s)[0];if(!u||typeof u!="string")return;const p=ua(),d=(i??[])?.map?.(b=>typeof b=="string"?b:void 0).filter(Boolean)??[],f=d.filter(b=>b&&(!p||p.includes(b))),h=o?.map?.(b=>{const[[,I]=[]]=Object.entries(b);return I}),v=n?.find?.(b=>b.type==="cover_art")?.attributes?.fileName,y=v?`https://mangadex.org/covers/${t}/${v}.256.jpg`:void 0,$=(l||[]).map(b=>b?.attributes?.name?.en).concat(c).filter(Boolean);return{url:`${location.origin}/title/${t}`,slug:t,name:u,altNames:h,langs:f.length>0?f:d.length>0?d:["en"],img:y,tags:e($)}}function ua(){const a=localStorage.getItem("md");if(a)try{const e=JSON.parse(a)?.userPreferences?.filteredLanguages;return e?.length?e:void 0}catch{return}}var ga=Object.defineProperty,pa=(a,e,t)=>e in a?ga(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,da=(a,e,t)=>(pa(a,e+"",t),t);class xe extends w{async getRawReaderData(){if((await P(".current-viewtype",{lazy:!0,all:!1}))?.textContent?.trim().toLowerCase()!=="volume")return await super.getRawReaderData()}async getRawChaptersData(){const e=this.context.lang??"en",t=await P(`.tab-content[data-name="chapter"] a.dropdown-item[data-code="${e.toUpperCase()}"]`,{lazy:!0,all:!1});if(t)return G(t),await P(`.tab-content[data-name="chapter"] li.item[data-number] a[href*="/${e}/"]`,{lazy:!0,all:!1}),await super.getRawChaptersData()}async getRawSearchData(){const e=await super.getRawSearchData();if(!e)return;const t=this.context.lang??"en";return{...e,rawReleases:e.rawReleases.map(r=>({...r,lang:r.lang??t}))}}}da(xe,"specId","mangafire");var ha=Object.defineProperty,fa=(a,e,t)=>e in a?ha(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,ma=(a,e,t)=>(fa(a,e+"",t),t);class De extends w{async getRawReaderData(){const e=await super.getRawReaderData();return e&&{...e,imgs:await this.getImgs()}}parseReaderSlug(e,t){const{slug:r,basePath:n}=super.parseReaderSlug(e,t),s=r.split("/").filter(Boolean),i=s[s.length-1];return{basePath:n,slug:i.startsWith("pg-")?s.slice(0,-1).join("/"):r}}async getImgs(){const e=await D(100,20,()=>window.imgsrcs),t=window.CryptoJS,r=t.enc.Hex.parse("e11adc3949ba59abbe56e057f20f883e"),n={iv:t.enc.Hex.parse("1234567890abcdef1234567890abcdef"),padding:t.pad.ZeroPadding};return t.AES.decrypt(e,r,n).toString(t.enc.Utf8).split(",")}}ma(De,"specId","mangago");var wa=Object.defineProperty,va=(a,e,t)=>e in a?wa(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,ya=(a,e,t)=>(va(a,e+"",t),t);class Me extends w{async getRawTitleData(){const e=`https://backend.${location.host}`,t=await S(e,"chapters-with-ids",T,T),r=await super.getRawTitleData();if(!(!t?.value||!r))return{...r,langs:await ba(),chapters:Y(t.value)}}async getRawChaptersData(){const e=L();if(e)return{chapters:Y(e)}}async getRawReaderData(){const e=`https://backend.${location.host}`,[t,r]=await Promise.all([S(e,"chapters-with-ids",T,T),S(e,"read",T)]);if(!t?.value||!r?.value?.length)return;const n=await super.getRawReaderData();if(!n)return;const s=new URLSearchParams(location.search).get("number")??"0";return{...n,slug:`${n.slug}?number=${s}`,imgs:r.value,title:{...n.title,chapters:Y(t.value)}}}}ya(Me,"specId","mangahaven");async function ba(){const a=document.querySelector('[role="tabpanel"] button');if(!a)return;const e=document.createElement("style");e.innerHTML="[data-radix-popper-content-wrapper] { display: none !important; }",document.head.appendChild(e),a.click();const t=await D(50,10,()=>N('img[src*="/flags/"]|attr:src|pattern:.+/(.+).svg'));return a.click(),setTimeout(()=>document.head.removeChild(e),1e3),t}function Y(a){const e=[];return a?.forEach?.(t=>{const r=+t.chapter;isNaN(r)||!t.id||e.push({chap:r,slug:`${t.id}?number=${t.chapter}`,lang:t.lang?.toLowerCase?.()})}),e}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,e+"",t),t);class Te extends J{}Sa(Te,"specId","mangapill");var xa=Object.defineProperty,Da=(a,e,t)=>e in a?xa(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,Ma=(a,e,t)=>(Da(a,e+"",t),t);class Ie extends w{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]}))}}}Ma(Ie,"specId","mangaplus");var Ta=Object.defineProperty,Ia=(a,e,t)=>e in a?Ta(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,Pa=(a,e,t)=>(Ia(a,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((n,s)=>s.time-n.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:we(location.pathname,"/")},n=e.title,s=document.querySelector(n.sel)??void 0;if(!s)return;const i=x(g(n.url,s));if(i===void 0)return;const o=s.querySelector(n.chapter.sel)??void 0;if(!(!o||x(g(n.chapter.url,o))===void 0))return r.titleBase=this.extractBasePath(i),t.titleIdType===F.id&&(g(n.id,s)||(t.titleIdType=F.name)),this.finalizeNewSiteMeta(t,r)}finalizeNewSiteMeta(e,t){if(this.siteId==="realm")return;const r=Object.keys(t),n={...e};let s=!1;return r.forEach(i=>{const o=t[i];o!==e[i]&&(n[i]=o,s=!0)}),s?n:void 0}}Pa(Pe,"specId","mangastream");var Ca=Object.defineProperty,Ba=(a,e,t)=>e in a?Ca(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,La=(a,e,t)=>(Ba(a,e+"",t),t);class Ce extends w{async getRawReaderData(){const e=await super.getRawReaderData();return e&&{...e,slug:e.slug.split("/").slice(0,-1).join("/")||e.slug.split("/")[0]}}}La(Ce,"specId","mangaworld");var Oa=Object.defineProperty,ja=(a,e,t)=>e in a?Oa(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,Aa=(a,e,t)=>(ja(a,e+"",t),t);class Be extends w{async getRawTitleData(){const e=await super.getRawTitleData();if(e)return{...e,hasMoreChapters:e.chapters.length===50}}}Aa(Be,"specId","mgeko");var Ea=Object.defineProperty,Na=(a,e,t)=>e in a?Ea(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,_a=(a,e,t)=>(Na(a,e+"",t),t);class Le extends W{async getRawReleasesData(){}async getRawSearchData(){}async getRawTitleData(){const e=await Oe();if(!e)return;const t=g("#cover img|[attr:data-src,attr-contain:src]")??e.img;return{...e,img:t,imgBytes:this.context.includeImgBytes&&e.img?await q(e.img):void 0}}async getRawReaderData(){const e=await Oe();if(!e)return;const t=g("#image-container img|[attr:data-src,attr-contain:src]"),r=H(t);if(!r)return;const n=r.pathname.split("/").filter(Boolean).slice(0,-1).join("/"),s=`${r.origin}/${n}/`,i=r.pathname.split("?")[0].split("#")[0].split(".").slice(-1)[0]||"webp";return{chap:0,slug:"1",basePath:e.url.replace(location.origin,"").slice(1),imgs:Array.from({length:e.totalImgs},(o,l)=>`${s}${l+1}.${i}`),title:{name:e.name,slug:e.slug,url:e.url,chapters:[{slug:"1",chap:0}]}}}async getRawChaptersData(){const e=await this.getRawTitleData();if(!e)return;const{chapters:t,...r}=e;return{title:{...r,chapters:[]},chapters:t}}}_a(Le,"specId","nhentai");async function Oe(){const a=await D(100,20,()=>window._gallery);if(!a?.id||!a?.title||!a?.images?.pages)return;const{title:e,images:{pages:t,cover:r},media_id:n}=a;return{name:e.pretty??e.english??e.japanese,slug:a.id+"",url:`${location.origin}/g/${a.id}`,chapters:[{slug:"1",chap:0}],totalImgs:t.length,img:await za(n,r.t)}}async function za(a,e){if(!a||!e)return;const t={j:"jpg",p:"png",g:"gif",w:"webp"}[e];if(!t)return;const r=(await D(10,20,()=>window._n_app))?.options?.thumb_cdn_urls?.[0];if(r)return`https://${r}/galleries/${a}/cover.${t}`}var ka=Object.defineProperty,Wa=(a,e,t)=>e in a?ka(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,Ua=(a,e,t)=>(Wa(a,e+"",t),t);class je extends w{async getRawChaptersData(){const e=L();if(e)return{chapters:B(e.map(qa).filter(Boolean))}}}Ua(je,"specId","qi");function qa(a){if(!(!a||typeof a.number!="number"))return{chap:a.number,slug:typeof a.slug=="string"?a.slug:void 0,ts:typeof a.createdAt=="string"?new Date(a.createdAt).valueOf():void 0}}var Ga=Object.defineProperty,Fa=(a,e,t)=>e in a?Ga(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,Ha=(a,e,t)=>(Fa(a,e+"",t),t);class Ae extends w{finalizeRawReaderData(e,{prevSlug:t,nextSlug:r}={}){if(!e.title.chapters.length){const n=C(t?.split(".").slice(0,-1).join(".")),s=C(r?.split(".").slice(0,-1).join("."));return!n&&!s?e:{...e,prev:n?{...n,slug:t}:void 0,next:s?{...s,slug:r}:void 0}}return super.finalizeRawReaderData(e,{prevSlug:t,nextSlug:r})}}Ha(Ae,"specId","rawkuma");var Va=Object.defineProperty,Ja=(a,e,t)=>e in a?Va(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,Qa=(a,e,t)=>(Ja(a,e+"",t),t);class Ee extends w{async getRawTitleData(){const e=await super.getRawTitleData();if(!e)return;const t=N(".info-detail__row > .genre-btn,.info__right .stats__row:first-child|text")?.map(r=>[r,...r.split(" ")]).flat();return Ne({...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:{...Ne({...e.title,url:t,tags:[]},".episode-list .js-ep-cnt"),hasMoreChapters:!1}}}async getRawChaptersData(){const{rawId:e,skip:t}=this.context,r=1e3,n=t?Math.floor(t/1e3)+1:1;try{const s=await fetch(`/series/${e}/episodes?page=${n}&sort=NEWEST&max_limit=${r}`);return Ya(await s.json())}catch{return}}parseTitleSlug(e){if(!e)return{};const t=e.split("/").filter(Boolean);return{slug:t[1]??t[0]}}}Qa(Ee,"specId","tapas");function Ne(a,e){const t=Ka(e)>20;return{...a,chapters:t?[]:a.chapters,hasMoreChapters:t}}function Ya(a){const e=a?.data?.episodes;if(!Array.isArray(e))return;const t=e.map(n=>({chap:n.pending_scene??n.scene,slug:n.id+"",ts:new Date(n.publish_date)?.valueOf?.()||void 0})),r=a?.data?.pagination;return{chapters:t,total:r?.total??t.length,hasMore:!!r?.has_next}}function Ka(a){return+(document.querySelector(a)?.textContent?.trim().split(" ")[0]||0)}var Za=Object.defineProperty,Xa=(a,e,t)=>e in a?Za(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,er=(a,e,t)=>(Xa(a,e+"",t),t);class _e extends w{async getRawTitleData(){const e=new URLSearchParams(location.search),t=e.get("episode_no"),r=e.get("title_no");if(t||!r)return;const n=await super.getRawTitleData();if(!n)return;const s=location.hostname.startsWith("m."),i=location.pathname.split("/")[1];return{...n,slug:`${n.slug}?title_no=${r}`,id:r,langs:i?[i]:void 0,chapters:s?[]:n.chapters.map(o=>({...o,lang:i})),hasMoreChapters:s||(document.querySelector(".paginate")?.childElementCount??1)>1}}async getRawReaderData(){const e=new URLSearchParams(location.search),t=e.get("episode_no"),r=e.get("title_no"),n=t?+t:void 0;if(!t||!r||typeof n!="number"||isNaN(n))return;const s=document.title.split("|")[1]?.trim();if(!s)return;const i=location.pathname.split("/"),o=`${i.slice(0,4).join("/")}/list?title_no=${r}`,l=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 || a|attr:href|pattern:.+episode_no=(\\d+).*"},{lazy:!1,titleId:r,titleSlug:o}),c=i[1];return{chap:n,lang:c,slug:`${location.pathname}?title_no=${r}&episode_no=${t}`,basePath:"",imgs:await this.getReaderImgs(),isWebtoon:!0,title:{id:r,url:o,slug:o,name:s,langs:[c],chapters:(l??[]).map(u=>({...u,lang:c})),hasMoreChapters:!1}}}async getReaderImgs(){const e=N("#_imageList img|[attr:data-url,attr:src]");return e?.length?e:await D(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 n=H(r);return{basePath:"",slug:n.pathname+n.search}}return{basePath:"",slug:r}}}er(_e,"specId","webtoon");const tr=[ce,ue,J,ge,pe,de,me,Q,ye,Re,xe,De,Me,Te,Ie,Pe,Be,Ce,Le,je,Ae,Ee,_e];function ze(a){const e=tr.find(t=>t.specId===a.spec.id)??w;return new e(a)}async function ar(a){const{spec:e}=a,t=a.siteMeta??e?.meta;if(e&&t){const r=a.type?[a.type]:ke(t,e.generic);if(!r.length)return;const n=ze({...a,spec:e,siteMeta:t});return await E(r.map(s=>n.getRawPageByType(s,r.length>1)))}return await E((a.genericSpecs??[]).map(r=>{if(!r.meta||!r.generic)return[];const n=ke(r.meta,r.generic);if(!n.length)return[];const s=ze({...a,spec:r,siteMeta:r.meta});return n.map(i=>s.getRawPageByType(i,!0))}).flat())}function ke(a,e){if(location.pathname==="/")return[];const{titleBase:t,readerBase:r}=a,n=location.pathname.split("/").filter(Boolean),s=We(n,r),i=We(n,t);if(s&&i)return[R.reader,R.title];const o=[];return!i&&(s!==!1||e)&&o.push(R.reader),!s&&(i!==!1||e)&&o.push(R.title),!o.length&&e?[R.reader,R.title]:o}function We(a,e){if(!e)return;const t=e.split("/").filter(Boolean),r=t.indexOf("{slug}"),n=r===t.length-1,s=!n&&r!==-1;if(n&&(t.pop(),!t.length))return;const i=a.length-t.length;if(s?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===(s?0:1))return!0}A.PageType=R,A.scrape=ar});
|