gildas-lormeau / SingleFileZ

Web Extension to save a faithful copy of an entire web page in a self-extracting ZIP file
GNU Affero General Public License v3.0
1.82k stars 140 forks source link

The iframe base64 in the generated page is too large, resulting in a blank page #188

Closed zhang-glitch closed 3 months ago

zhang-glitch commented 4 months ago

When downloading this website, the base64 url generated for the iframe in the pop-up section is too large, causing the pop-up section to not be displayed. image

generated page

image

Then convert the base64 url to a blob url and you can display it directly.

const base64Url = ""
const iframe = document.querySelector('iframe');
iframe.src = base64Url // blank

// base64 url to blob url
var byteCharacters = atob(base64Url.split(',')[base64Url.split(',').length - 1]);
var byteNumbers = new Array(byteCharacters.length);
for (var i = 0; i < byteCharacters.length; i++) {
    byteNumbers[i] = byteCharacters.charCodeAt(i);
}
var byteArray = new Uint8Array(byteNumbers);
console.log(base64Url.split(',')[0].split(":")[1]);
var file = new Blob([byteArray], { type: base64Url.split(',')[0].split(":")[1] });
var fileURL = URL.createObjectURL(file);

iframe.src = fileURL // display

base64 url,blank image blob url , display image

zhang-glitch commented 4 months ago

website URL: https://cms.demo.fastadmin.net/admin.php/index/login

gildas-lormeau commented 3 months ago

Thank you, I implemented an optimization where the top-level frames will use Blob URIs as source instead of data URIs when self-extracting the page. It should fix the issue you described (I was not able to test it with the URL of the website). The fix will be available in the next version of SingleFile. In order to be compliant with MV3 among other things, SingleFileZ has been merged into SingleFile and is not maintained anymore.