/E-Hentai-Downloader

Download E-Hentai archive as zip file

Primary LanguageJavaScriptGNU General Public License v3.0GPL-3.0

E-Hentai-Downloader

Download E-Hentai archive as zip file 📦

Required Environment

Browser GreaseMonkey Tampermonkey Violentmonkey
Firefox (56-) 3.2 beta2+
Firefox (57+) 4.1 beta5+ 4.0.5054+ 2.8.18+
Chrome 3.5.3630+ 2.2.6+
Opera (15+) 3.5.3630+ 2.1.10+
Safari (10.1+) (1) 4.3.5421+
Edge (18-) (2) 4.2.5284+
Edge (79+) 4.10.6111+ 2.12.8+
Maxthon 2.1.10+
Yandex Browser for Android (3) 4.2.5291+ 2.2.6+
Kiwi Browser (3) 4.11+ 2.12.8+
Firefox for Android (68-)(3) Incompatible Incompatible 2.12.8+
Firefox Nightly for Android (85+) (3)(4) Incompatible 4.11.6120+ 2.12.8+

(1) You must upgrade your Windows 10 to 14393 which supports Edge extension.
(2) You must upgrade your macOS to 10.12.4 which supports download attribute of <a> tag.
(3) It's not a good idea to use it on mobile with limited RAM, but it can work, so it's up to you.
(4) Firefox Nightly user requires to follow this steps to install extensions not in default list.

Install This Script

How To Use

  1. Open E-Hentai Gallery
  2. Find your interested gallery
  3. Click "Download Archive" in E-Hentai Downloader box
  4. Have a cup of coffee ☕
  5. Save the Zip file

E-Hentai Downloader box

Tips:

  • Check "Number Images" to number download images
  • Set "Pages Range" to choose pages you want to download
  • More personalized options can be found on "Settings"

How It Works

This script won't download archive from E-Hentai archive download page, so it won't spend your GPs or credits. It will fetch all the pages of the gallery and get their images' URL. Then script will use GM_xmlhttpRequest API (in order to cross origin) to download them. After that, it will package them to a Zip file with JSZip and give it to you with FileSaver.js.

Should Be Noticed

  • The script is NOT provided by the offical, and using automated scripts/tools is NOT encouraged and may trigger throttle limit or even account ban, DON'T BOTHER ANYONE IN SITE FORUMS FOR ANY SCRIPT-RELATED ISSUE, AND USE AT YOUR OWN RISK.
    If you're downloading a large gallery, please consider using torrents if available, or using offical archiver for better and stable experience, and the cost should be closed to using script when the gallery is old enough to use GPs.
    For the detail rules, see E-Hentai Image Viewing Limits.
  • If you see a message about out of memory on Firefox, or file not found on Chrome, see solution here.
    In short, use Pages Range to limit each zip file under 500 MB is recommended, and enable File System if you're using Chrome, or upgrade your PC with more RAM.
    However there're some hard limits, like 2 GB Blob Object limit on browser, and 4 GB size limit on ZIP itself. For such cases (and stability) please try other tools like gallery-dl.
  • You can also have a look at E-Hentai Image Viewing Limits.
  • Most of galleries may have torrents to download. You can download archive with torrent to get stable download experience, get bonus content (most in cosplay gallery), earn GP and credit, and reduce the pressure of E-Hentai original servers (though it's a P2P site).

Here are some other compatible information (and some of them are backed to around 10 years ago), which is not important.

  • Tampermonkey uses a dirty way to give GM_xhr.response content (transfers String to ArrayBuffer everytime), so it'll stuck for 1~3 seconds or more after downloaded image (depend on your device). If you are using Microsoft Edge, you may often see the working tab is stuck, saying it's not responding. Just let it go and do nothing. And if you are using Firefox, it's better to use GreaseMonkey from this side.
    The freeze problem should be fixed in Tampermonkey 4.12.6125.
  • If you are using the latest Tampermonkey, or receive a warning of "A userscript wants to access a cross-origin resource" from Tampermonkey, please Allow All or turn off "@connect mode" at setting page. For more info, see details here.
    E-Hentai now uses hath.network domain to access images, and it's now listed in @connect, so you're not needed to set this with latest Tampermonkey.
  • ViolentMonkey doesn't support timeout, final URL and download progress.
    The latest ViolentMonkey supports these features now.
  • Single-thread download mode is removed in 1.18, if you need it, roll back to old version.
    Don't use an old version, it doesn't support current site.
  • Dolphin Browser (Android) doesn't support blob URL, so this script cannot be run in Tampermonkey for Dolphin probably.
  • UC Browser (Android) doesn't support blob constructor, so this script cannot be run in Tampermonkey for UC probably.
  • Opera 12- doesn't support blob URL, and if generated as data URL, it may crash, so it's not supported.
  • TrixIE (for IE) is too old and its GM_xhr cannot handle large content, so it's not supported.

Warning And Limitation

Memory Usage

The script will store ALL the data in RAM, not in HDD. This will increase the memory usage of current tab process. So if you don't have enough RAM, or the archive is too large (see file size limit section), please pay attention to your memory usage, or try other download tools.

"Out of memory" problem is the most limitaion of the script (in fact, all the sections of "Warning And Limitation" are about RAM problem, and here is also a specific out of memory tag to label all related issues). If you get an error like out of memory, see solution here. And if you usually have the problem, try other tools.

Browser Developer Tools

To help us debug, the script will output some logs into console (F12 -> Console). If you find a bug, you can keep opening devtools to see and copy the logs. But note that it may increase memory usage and reduce running efficiency. So don't open console only if you want to see the output logs.

File Size Limit

(This part is a bit long, you can just read the table)

Different browsers have different maximum file size limits. Here is a table to show the maximum size the supported browser can handle.

Browser Maximum Size
Chrome 56- 500 MB
Chrome 57+ 2 GB or (total RAM / 5)
Chrome (with File System) 1 GB / > 2GB (with 1.33+)
Firefox 2 GB
Opera 15+ Same as Chrome
Edge 18- ?
Edge 79+ Same as Chrome
Safari 10.1+ ?
Maxthon ?

For Google Chrome 56-, it has a hard limit at 500 MB on Blob Storage for years. That means all the files that in storage cannot be larger than 500MB in total, and if the storage doesn't have enough free space to save the next file, it'll return a fake Blob instance silently without any errors. Also for Chrome 45-, Blob.close() didn't implement (and it's depreated so no browser supports it now), so we cannot free those used Blob immediately at that time, only to pary the browser will GC them ASAP (and for most of time it didn't work). That's why here is a wiki page to help you work around this.

So to help you save larger files, the script can save the Zip file into File System, a deprecated HTML5 API but still works on Chrome (as it's Chrome introduce the standard first). With the API, you can handle larger file because the file data will be writing to your disk instead of storing in Blob Storage, its limit is also big enough (10% of your disk free storage, 15 GB in maximum). But when processing the file, the files are still keeping in RAM, and if datas are too large, Chrome may also cannot handle them. From my test the maximum limit maybe 1 GB if you only have 8 GB RAM, but it may also depends on your device. If you have enough RAM, you can download a gallery larger than 2 GB with 1.33+.

Chrome 57+ fixes the 500 MB limit of Blob Storage, so that it can handler larger files in RAM just like File System. Its quota is still exist but it's larger, which bases on the limits below, and here are some examples to make it more clear:

In-memory quota:

  • 2GB if system is x64 and NOT ChromeOS or Android
  • Total RAM amount / 5;

Disk quota:

  • Disk size / 2 if ChromeOS (user partition disk size)
  • Disk size / 20 if Android
  • Disk size / 10 otherwise.

Also, if disk is almost full, we try to keep at least (in-memory quota)*2 disk space available, and we limit the disk quota accordingly.

For Firefox, from our previous data from FileSaver.js, the limit is 800 MB. But from our tests, you can save the file that larger than 800 MB. So we think the limit of Firefox is depending on your device, as it stores the Blob in RAM. If you have a larger RAM, you can save a larger file. However, you should care about your RAM usage, as if Firefox cannot get more RAM to generate Zip, it'll throw an "out of memory" error. To give you some advice, no more than 200 MB if you're using 4 GB RAM, and be care for more than 800 MB if you're using 8 GB RAM.

Opera 15+ is a Chromium-based browser, so you can check its Chromium version and compare it to Chrome version to get your limit. All the other Chromium-based browsers can also use this rule.

Safari 10.1+ finally supports download attribute on <a> tag, so you can now make it works on Safari. We don't have too much data about Safari Blob limit, so if you're dealing with Safari, be care about your RAM usage.

Todo List

See plans and progress here, notice that some of them may changed or removed in some time.

Report A Bug

You can report a bug or give suggestions at GitHub Issue or GreasyFork Feedback. English and Chinese are acceptable 😝

English is not my mother tounge, so if you found any mistakes, don't hesitate to let me know =ω=

Sorry my code is a bit untidy, so it may hard for your development. I'll try optimizing it in a further time 😅