Skip to content

Commit

Permalink
v1.13.4
Browse files Browse the repository at this point in the history
  • Loading branch information
ccloli committed Nov 13, 2021
1 parent dc1c7e1 commit 228111b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion e-hentai-downloader.meta.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// ==UserScript==
// @name E-Hentai Downloader
// @version 1.33.3
// @version 1.33.4
// @description Download E-Hentai archive as zip file
// @author 864907600cc
// @icon https://secure.gravatar.com/avatar/147834caf9ccb0a66b2505c753747867
Expand Down
18 changes: 10 additions & 8 deletions e-hentai-downloader.user.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// ==UserScript==
// @name E-Hentai Downloader
// @version 1.33.3
// @version 1.33.4
// @description Download E-Hentai archive as zip file
// @author 864907600cc
// @icon https://secure.gravatar.com/avatar/147834caf9ccb0a66b2505c753747867
Expand Down Expand Up @@ -12791,7 +12791,7 @@ function generateZip(isFromFS, fs, isRetry, forced){
// update progress table info
function updateProgress(nodeList, data) {
if (data.name !== undefined) nodeList.fileName.textContent = data.name;
if (data.progress !== undefined) nodeList.progress.value = data.progress;
if (data.progress !== undefined && !Number.isNaN(data.progress)) nodeList.progress.value = data.progress;
if (data.progressText !== undefined) nodeList.progressText.textContent = data.progressText;
if (data.status !== undefined) nodeList.statusText.textContent = data.status;
if (data.class !== undefined) nodeList.current.className = ['ehD-pt-item', data.class].join(' ').trim();
Expand Down Expand Up @@ -13036,7 +13036,7 @@ function fetchOriginalImage(index, nodeList) {

updateProgress(nodeList, {
name: '#' + imageList[index]['realIndex'] + ': ' + imageList[index]['imageName'],
progress: res.lengthComputable ? res.loaded / res.total : '',
progress: res.lengthComputable ? res.loaded / (res.total || 1) : '',
progressText: speedText,
class: '',
status: retryCount[index] === 0 ? 'Downloading...' : 'Retrying (' + retryCount[index] + '/' + (setting['retry-count'] !== undefined ? setting['retry-count'] : 3) + ') ...'
Expand Down Expand Up @@ -13080,15 +13080,10 @@ function fetchOriginalImage(index, nodeList) {
// (Tampermonkey uses a dirty way to give res.response, transfer string to arraybuffer every time)
// now store progress just spent ~1s instead of ~8s
var response = res.response;
var byteLength = response.byteLength;
var responseHeaders = res.responseHeaders;

// use regex to fixed compatibility with http/2, as its headers are lower case (at least fixed with Yandex Turbo)
var mime = responseHeaders.match(/Content-Type:/i) ? responseHeaders.split(/Content-Type:/i)[1].split('\n')[0].trim().split('/') : ['', ''];
var responseText;
if (mime[0] === 'text') {
responseText = new TextDecoder().decode(new DataView(response));
}

if (!response) {
console.log('[EHD] #' + (index + 1) + ': Empty Response (See: https://github.com/ccloli/E-Hentai-Downloader/issues/16 )');
Expand All @@ -13108,6 +13103,13 @@ function fetchOriginalImage(index, nodeList) {

// res.response polyfill is useless, so it has been removed
}

var byteLength = response.byteLength;
var responseText;
if (mime[0] === 'text') {
responseText = new TextDecoder().decode(new DataView(response));
}

if (byteLength === 925) { // '403 Access Denied' Image Byte Size
// GM_xhr only support abort()
console.log('[EHD] #' + (index + 1) + ': 403 Access Denied');
Expand Down

0 comments on commit 228111b

Please sign in to comment.