// ==UserScript== // @name JSZIP测试 // @namespace http://tampermonkey.net/ // @version 0.1 // @description try to take over the world! // @author You // @match https://bbs.tampermonkey.net.cn/forum.php // @icon https://www.google.com/s2/favicons?domain=tampermonkey.net.cn // @require https://cdn.staticfile.org/jszip/3.5.0/jszip.min.js // @require https://raw.githubusercontent.com/lihengdao666/Modify-Tampermonkey-Libs/master/filesaver.js // @grant unsafeWindow // @grant GM_xmlhttpRequest // ==/UserScript== var zip = new JSZip(); var outzip=new JSZip(); GM_xmlhttpRequest({ url:'https://raw.githubusercontent.com/lihengdao666/Modify-Tampermonkey-Libs/master/testfile/1.zip', responseType:'arraybuffer', method :"GET", headers: { }, onload:function(xhr){ zip.loadAsync(xhr.response).then(function(zip) { console.log('zip',zip) zip.file("26758f43cbc6b95fb7b534e5a59006b9.jpg").async("blob").then(function (data) { console.log('data',data) let img=document.createElement("img"); img.src=URL.createObjectURL(data) window.document.body.append(img) outzip.file("test/blob.jpg", data); zip.file("26758f43cbc6b95fb7b534e5a59006b9.jpg").async("arraybuffer").then(function (data) { console.log('arraybuffer',data) outzip.file("test/arraybuffer.jpg", data); zip.file("26758f43cbc6b95fb7b534e5a59006b9.jpg").async("uint8array").then(function (data) { console.log('uint8array',data) outzip.file("test/uint8array.jpg", data); outzip.generateAsync({type : "blob"}).then((res)=>{ console.log('out',res) saveAs(res,"美女.zip"); }) }); }); }); }).catch(val=> { alert('错误',val) }); } });