GM_archiveImages

打包下载图片

สคริปต์นี้ไม่ควรถูกติดตั้งโดยตรง มันเป็นคลังสำหรับสคริปต์อื่น ๆ เพื่อบรรจุด้วยคำสั่งเมทา // @require https://update.greasyfork.org/scripts/565289/1749527/GM_archiveImages.js

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey, Greasemonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

You will need to install an extension such as Tampermonkey to install this script.

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

ผู้เขียน
ssnangua
เวอร์ชัน
0.0.1.20260205211748
สร้างเมื่อ
05-02-2026
อัปเดตเมื่อ
05-02-2026
Size
2.07 กิโลไบต์
สัญญาอนุญาต
ไม่มี

需要引入以下依赖:GM_pLimitGM_requestJSZipFileSaver

// @require      https://update.greasyfork.org/scripts/565266/1749341/GM_pLimit.js
// @require      https://update.greasyfork.org/scripts/565272/1749374/GM_request.js
// @require      https://update.greasyfork.org/scripts/565290/1749444/JSZip-v391.js
// @require      https://update.greasyfork.org/scripts/565291/1749445/FileSaver-205.js
// @grant        GM_xmlhttpRequest

使用:

GM_archiveImages({
  images: [
    { name: "01.jpg", url: "https://..." },
    { name: "02.jpg", url: "https://..." },
  ],
  zip: "test.zip",
  concurrency: 10,
  maxRetries: 5,
  onload({ loaded, total }) {
    console.log(`下载图片:${loaded}/${total}`);
  },
  onretry({ url, currentRetry, maxRetries }) {
    console.warn(`下载失败,重试 ${currentRetry}/${maxRetries}:${url}`);
  },
  onerror({ url }) {
    console.warn(`下载失败:${url}`);
  },
  onloaded() {
    console.log("下载完成,开始打包…");
  },
  onarchive(percent) {
    console.log(`正在打包:${percent.toFixed(2)}%`);
  },
  oncomplete() {
    console.log("完成!");
  },
});