window.__kol_captureList={"/api/recommend/item_list/":"foryouVideoList","/api/post/item_list":"userVideoList","/api/repost/item_list":"userRepostList","/api/favorite/item_list":"userLikeList","/api/collection/item_list":"userFavoriteList","/api/user/collect/item_list/":"userPageFavoriteList","/api/search/general/full":"searchGeneralList","/api/search/item/full/":"searchVideoList","/api/explore/item_list/":"exploreVideoList","/api/challenge/item_list/":"tagVideoList","/api/following/item_list":"followingVideoList","/api/friends/item_list":"friendsVideoList","/api/music/item_list":"musicVideoList","/api/item/detail":"userVideoDetail","/api/shop/brandy_desktop/tiktok-ug":"relatedList","/api/shop":"shopList","/api/user/list/":"fansList","/api/comment/list/":"commentLsit","/api/effect/item/list/":"effectList"};window.__kol_captureList_xhr={"/creator_studio/inspiration/trending/video":"inspirationTrendingList"};window.__kol_captureList_urlReferer={"/api/post/item_list":"userVideoList","/api/comment/list/":"commentLsit","/api/user/list/":"fansList"};window.__KOL_EVENT_BUFFER__=[];window.__KOL_CONTENT_READY__=!1;function p(n){window.__KOL_CONTENT_READY__?setTimeout(()=>{window.dispatchEvent(n)},1500):window.__KOL_EVENT_BUFFER__.push(n)}function R(n){const{url:a,requestId:r}=n.detail||{};!a||!r||window.fetch(a,{credentials:"omit"}).then(c=>c.json().then(w=>{p(new CustomEvent("tikTokDataList",{detail:{data:w,requestId:r}}))}))}window.addEventListener("getTikTokData",R);function O(){const n=Object.keys(window.__kol_captureList),a=Object.keys(window.__kol_captureList_xhr),r=window.fetch;window.fetch=async function(...o){let e="",s;const t=o[0],i=o[1];if(typeof t=="string"?(e=t,s=i==null?void 0:i.credentials):t instanceof URL?(e=t.href,s=i==null?void 0:i.credentials):t instanceof Request&&(e=t.url,s=t.credentials),s==="omit")return r.apply(this,o);let u;for(let l=0;l<n.length;l++){const _=n[l];if(e.includes(_)){u=_;break}}if(!u)return r.apply(this,o);const f=await r.apply(this,o),y=f.headers.get("Content-Type")||"";return!f.ok||!y.includes("application/json")||f.clone().text().then(l=>{l&&queueMicrotask(()=>{try{const _=JSON.parse(l),L=new URLSearchParams(e);if(L.get("post_item_list_request_type")){const d=L.get("post_item_list_request_type");_.tkOrder=!d||d==="0"?"Latest":d==="1"?"Popular":"Oldest"}let k=_;if(u==="/api/user/list/"){const d={};new URLSearchParams(e.split("?")[1]||"").forEach((T,g)=>{d[g]=T}),k={..._,params:d}}p(new CustomEvent(window.__kol_captureList[u],{detail:k})),window.__kol_captureList_urlReferer[u]&&p(new CustomEvent("urlRefererGet",{detail:e}))}catch{}})}),f};const c=XMLHttpRequest.prototype,w=c.open,E=c.send,h=new WeakMap;c.open=function(o,e,...s){try{typeof e=="string"&&h.set(this,e)}catch{}return w.call(this,o,e,...s)},c.send=function(...o){const e=h.get(this)||"";let s;for(let t=0;t<a.length;t++){const i=a[t];if(e.includes(i)){s=i;break}}return s&&this.addEventListener("loadend",()=>{try{const t=this.responseText;if(!t)return;const i=JSON.parse(t);p(new CustomEvent(window.__kol_captureList_xhr[s],{detail:{data:i,fetchURL:e}}))}catch{}},{once:!0}),E.apply(this,o)};const m=window.localStorage.getItem("fyp-feed-cache");m&&queueMicrotask(()=>{try{p(new CustomEvent("foryouVideoList",{detail:JSON.parse(m)}))}catch{}}),queueMicrotask(()=>{p(new CustomEvent("refreshUserProfile"))}),console.log("inject success")}window.addEventListener("kolContentReady",n=>{window.__KOL_CONTENT_READY__=!0,window.__KOL_EVENT_BUFFER__.forEach(a=>{setTimeout(()=>{window.dispatchEvent(a)},1500)}),window.__KOL_EVENT_BUFFER__=[]});window.__load_kol_ss=!0,setTimeout(()=>{window.__load_kol_main?document.documentElement.dataset.__load_kol_main="true":O()},1);
