GM_archiveImages

打包下载图片

Tento skript by neměl být instalován přímo. Jedná se o knihovnu, kterou by měly jiné skripty využívat pomocí meta příkazu // @require https://update.greasyfork.org/scripts/565289/1749527/GM_archiveImages.js

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

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

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

Autor
ssnangua
Verze
0.0.1.20260205211748
Vytvořeno
05. 02. 2026
Aktualizováno
05. 02. 2026
Size
2,1 KB
Licence
neuvedeno

需要引入以下依赖: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("完成!");
  },
});