Greasy Fork is available in English.
传入zip文件链接,返回其中第一个txt文件中的内容。
当前为
此脚本不应直接安装。它是供其他脚本使用的外部库,要使用该库请加入元指令 // @require https://update.greasyfork.icu/scripts/475748/1253637/zip%E8%A7%A3%E5%8E%8B%E5%B7%A5%E5%85%B7.js
// ==UserScript==
// @name zip解压工具
// @namespace unzipandreadtext
// @version 0.0.1
// @description 传入zip文件链接,返回其中第一个txt文件中的内容。
// @author sehuatang_chen
// @license MIT
// @match https://d2wpb.com/*
// @grant GM_xmlhttpRequest
// @grant GM_getValue
// @grant GM_setValue
// @grant GM_addStyle
// @grant GM_registerMenuCommand
// @require https://cdn.bootcdn.net/ajax/libs/jszip/3.9.1/jszip.min.js
// ==/UserScript==
headers={
'User-agent': navigator.userAgent,
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7',
}
function readZip(link) {
return new Promise((resolve, reject) => {
const jszip = new JSZip()
GM_xmlhttpRequest({
method: 'GET',
url: link,
headers: headers,
responseType: 'blob',
onload: (result) => {
if (result.status === 200 || result.status === 304) {
jszip.loadAsync(result.response).then(zip => resolve(zip)).catch(err => reject(err));
}else{
reject("download err.")
}
}
});
})
}
function readfirsttxtfileinzip(link){
return readZip(link).then(zip => {
for (let key in zip.files) {
if (!zip.files[key].dir) {
return zip.file(zip.files[key].name).async('string')
}
}
})
}