|
|
@@ -515,6 +515,7 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => {
|
|
|
imgElement.setAttribute("src", EMPTY_IMAGE);
|
|
|
} else {
|
|
|
if (imageData.currentSrc) {
|
|
|
+ imgElement.dataset.singleFileOriginURL = imgElement.getAttribute("src");
|
|
|
imgElement.setAttribute("src", imageData.currentSrc);
|
|
|
}
|
|
|
if (this.options.loadDeferredImages) {
|
|
|
@@ -1371,7 +1372,7 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => {
|
|
|
// ---------------
|
|
|
const DATA_URI_PREFIX = "data:";
|
|
|
const ABOUT_BLANK_URI = "about:blank";
|
|
|
- const EMPTY_DATA_URI = "data:base64,";
|
|
|
+ const EMPTY_DATA_URI = "data:null;base64,";
|
|
|
const REGEXP_URL_HASH = /(#.+?)$/;
|
|
|
const SINGLE_FILE_VARIABLE_NAME_PREFIX = "--sf-img-";
|
|
|
const VAR_MAX_SIZE = 1024 * 1024 * 2;
|
|
|
@@ -1679,7 +1680,24 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => {
|
|
|
// ignored
|
|
|
}
|
|
|
if (Util.testValidURL(resourceURL)) {
|
|
|
- const { content, indexResource, duplicate } = await batchRequest.addURL(resourceURL, true, resourceElement.tagName == "IMG" && attributeName == "src");
|
|
|
+ let { content, indexResource, duplicate } = await batchRequest.addURL(resourceURL, true, resourceElement.tagName == "IMG" && attributeName == "src");
|
|
|
+ if (resourceElement.dataset.singleFileOriginURL) {
|
|
|
+ const originURL = resourceElement.dataset.singleFileOriginURL;
|
|
|
+ delete resourceElement.dataset.singleFileOriginURL;
|
|
|
+ if (content == EMPTY_DATA_URI) {
|
|
|
+ try {
|
|
|
+ resourceURL = originURL;
|
|
|
+ content = (await util.getContent(resourceURL, {
|
|
|
+ asBinary: true,
|
|
|
+ maxResourceSize: options.maxResourceSize,
|
|
|
+ maxResourceSizeEnabled: options.maxResourceSizeEnabled,
|
|
|
+ frameId: options.windowId
|
|
|
+ })).data;
|
|
|
+ } catch (error) {
|
|
|
+ // ignored
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
if (removeElementIfMissing && content == EMPTY_DATA_URI) {
|
|
|
resourceElement.remove();
|
|
|
} else {
|