Closed ccloli closed 7 years ago
Working on it but still no luck...
(function() {
'use strict';
function createBlob(data, config){
try {
return new Blob(data, config);
}
catch(e){}
}
var ab = new ArrayBuffer(10000000);
var blob = createBlob([ab], {type: 'application/zip'});
var url = URL.createObjectURL(blob);
var a = document.createElement('a');
a.setAttribute('download', 'file');
a.setAttribute('href', url);
var clickEvt = new MouseEvent('click');
a.dispatchEvent(clickEvt);
})();
Here is a script that describes how E-Hentai Downloader gives the file, it works fine on Chrome, or even in Tampermonkey sandbox. I also tried save it with FileSaver.js
(function() {
'use strict';
function createBlob(data, config){
try {
return new Blob(data, config);
}
catch(e){}
}
var ab = new ArrayBuffer(10000000);
var blob = createBlob([ab], {type: 'application/zip'});
saveAs(blob, 'file')
})();
Both pure browser environment and Tampermonkey are fine, without any warning of "Failed - No File". The same result with JSZip.
Tried exploding the ArrayBuffer data to global variable in E-Hentai Downloader. When downloading, Chrome says "Failed - No File", but when I use the first code to download the ArrayBuffer data that exploded to window
, it downloads successful.
Not sure what's up.
Got it. Here is the problem.
saveAs(blob, fileName + '.zip');
// ...
if ('close' in blob) blob.close();
blob = null;
It seems that on latest Chrome it implements the Blob.close()
API. So that when the file is being downloaded, the Blob object has been revoked.
Blob.close()
Closes the blob object, possibly freeing underlying resources. -- ref: https://developer.mozilla.org/en-US/docs/Web/API/BlobsaveAs(blob, fileName + '.zip');
// ... setTimeout(function(){ if ('close' in blob) blob.close(); blob = null; }, 1000);
Use a timer will fixed the bug.
Fixed in 1.26.2, it will delays about 10 seconds to do blob.close()
, that should be enough to download a file. If you still have the bug, Not download? Click here to download
would really works now :-)
Thought mentioned in wiki, that we can try clicking
Not download? Click here to download
until it gives the file, it seems that it sometimes not working.From my recent test, with Chrome 57.0.2987.133, I tried it some times, but it still said "Failed- No File". I also checked my RAM (8GB) usage, only about 66% are used, and from Chrome Blob usage, all of them don't have file data, which likes the Blob storage is used up. This not only happens on Tampermonkey but also Violentmonkey.
Finally I set it always use File System to store files, and it works fine now.
I'm not sure if you have this bug or just only me, if you also occurred this problem, please note here, and try my settings.