chrome.runtime.onInstalled.addListener(()=>{}),chrome.runtime.onMessage.addListener((e,a,o)=>{if("proxyFetch"===e.action)return(async()=>{try{const a=(await chrome.cookies.getAll({domain:"alibaba.com"})).map(e=>`${e.name}=${e.value}`).join("; "),t={method:e.method||"GET",headers:{Cookie:a,...e.headers}};if(e.method&&"POST"===e.method.toUpperCase())if(e.fileData){const{arrayBuffer:a,name:o,type:r}=e.fileData,n=new Blob([new Uint8Array(a)],{type:r}),s=new FormData;if(s.append("file",n,o),e.params)for(const t in e.params)s.append(t,e.params[t]);t.body=s,delete t.headers["Content-Type"]}else e.isFormUrlEncoded?(t.body=new URLSearchParams(e.body).toString(),t.headers["Content-Type"]="application/x-www-form-urlencoded"):e.body&&(t.body=JSON.stringify(e.body),t.headers["Content-Type"]||(t.headers["Content-Type"]="application/json"));const r=await fetch(e.url,t);if(!r.ok)throw new Error(`HTTP error! status: ${r.status}`);const n=await r.json();o({success:!0,data:n})}catch(a){o({success:!1,error:a.message})}})(),!0});
