Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (function(){const N=350,T="/backend/nf/create";const f=window.fetch;const mutateBody=b=>{if(b==null)return b;if(typeof b==="string"){try{const j=JSON.parse(b);j.n_frames=N;if("size"in j)j.size="small";else j.size="small";return JSON.stringify(j);}catch(_){let out=b.replace(/"n_frames"\s*:\s*\d+/g,`"n_frames": ${N}`);out=out.replace(/"size"\s*:\s*"(?:[^"]*)"/g,`"size": "small"`);return out;}}if(typeof FormData!=="undefined"&&b instanceof FormData){if(b.has("n_frames"))b.set("n_frames",String(N));else b.append("n_frames",String(N));if(b.has("size"))b.set("size","small");else b.append("size","small");return b;}if(typeof URLSearchParams!=="undefined"&&b instanceof URLSearchParams){b.set("n_frames",String(N));b.set("size","small");return b;}return b;};window.fetch=async function(i,n){try{const url=typeof i==="string"?i:(i&&i.url)||"";const method=(n&&n.method)||(typeof i==="object"&&i.method)||"GET";if(url.includes(T)&&String(method).toUpperCase()==="POST"){if(n&&"body"in n){n={...n,body:mutateBody(n.body)};}else if(typeof i==="object"&&i instanceof Request){const c=i.clone();let newBody=undefined;try{const ct=c.headers.get("content-type")||"";if(/json|text|application\/.*\+json/i.test(ct)){const txt=await c.text();newBody=mutateBody(txt);}else{try{const fd=await c.formData();newBody=mutateBody(fd);}catch{const txt=await c.text();newBody=mutateBody(txt);}}}catch{}if(newBody!==undefined){i=new Request(c,{body:newBody});}}}}catch(_){}return f.apply(this,[i,n]);};const o=XMLHttpRequest.prototype.open,s=XMLHttpRequest.prototype.send;XMLHttpRequest.prototype.open=function(m,u){this.__m=m;this.__u=u;return o.apply(this,arguments)};XMLHttpRequest.prototype.send=function(b){try{if(this.__u&&this.__u.includes(T)&&String(this.__m).toUpperCase()==="POST"){if(typeof b==="string"){b=mutateBody(b);}else if((typeof FormData!=="undefined"&&b instanceof FormData)||(typeof URLSearchParams!=="undefined"&&b instanceof URLSearchParams)){b=mutateBody(b);}}}catch(_){}return s.call(this,b);};})();
Advertisement
Add Comment
Please, Sign In to add comment