mirror of
https://github.com/the1812/Bilibili-Evolved.git
synced 2025-11-04 21:22:45 +08:00
1 line
832 B
JavaScript
1 line
832 B
JavaScript
(()=>{return(e,t)=>{class n{constructor(e={}){this.config=e;this.entries=[]}download(e,t){const n=document.createElement("a");const i=URL.createObjectURL(t);n.setAttribute("href",i);n.setAttribute("download",e);document.body.appendChild(n);n.click();n.remove();URL.revokeObjectURL(i)}add(e,t){if(t===null||t===undefined){return}this.entries.push({name:e,data:t})}async emit(e){if(this.entries.length===0){return}if(!e||this.entries.length===1){e=this.entries[0].name}if(this.entries.length===1){const t=this.entries[0].data;this.download(e,typeof t==="string"?new Blob([t]):t);return}const t=new JSZip;this.entries.forEach(({name:e,data:n})=>{t.file(e,n)});const n=await t.generateAsync({type:"blob"});this.download(e,n)}static async single(e,t){const i=new n;i.add(e,t);await i.emit()}}return{export:{DownloadVideoPackage:n}}}})(); |