|
@@ -349,7 +349,7 @@ const SingleFileCore = (() => {
|
|
|
style.textContent = this.options.compressCSS ? this.dom.uglifycss(stylesheetContent) : stylesheetContent;
|
|
style.textContent = this.options.compressCSS ? this.dom.uglifycss(stylesheetContent) : stylesheetContent;
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
- }
|
|
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
removeHiddenElements() {
|
|
removeHiddenElements() {
|
|
|
this.doc.querySelectorAll("[" + REMOVED_CONTENT_ATTRIBUTE_NAME + "]").forEach(element => element.remove());
|
|
this.doc.querySelectorAll("[" + REMOVED_CONTENT_ATTRIBUTE_NAME + "]").forEach(element => element.remove());
|
|
@@ -449,25 +449,14 @@ const SingleFileCore = (() => {
|
|
|
await Promise.all(frameElements.map(async (frameElement, frameIndex) => {
|
|
await Promise.all(frameElements.map(async (frameElement, frameIndex) => {
|
|
|
const frameWindowId = (this.options.windowId || "0") + "." + frameIndex;
|
|
const frameWindowId = (this.options.windowId || "0") + "." + frameIndex;
|
|
|
const frameData = this.options.framesData.find(frame => frame.windowId == frameWindowId);
|
|
const frameData = this.options.framesData.find(frame => frame.windowId == frameWindowId);
|
|
|
|
|
+ const setFrameEmptySrc = frameElement => frameElement.setAttribute(frameElement.tagName == "OBJECT" ? "data" : "src", EMPTY_DATA_URI);
|
|
|
if (frameData) {
|
|
if (frameData) {
|
|
|
if (initialization) {
|
|
if (initialization) {
|
|
|
- const options = {
|
|
|
|
|
- insertSingleFileComment: false,
|
|
|
|
|
- insertFaviconLink: false,
|
|
|
|
|
- url: frameData.baseURI,
|
|
|
|
|
- windowId: frameWindowId,
|
|
|
|
|
- removeHiddenElements: this.options.removeHiddenElements,
|
|
|
|
|
- removeUnusedCSSRules: this.options.removeUnusedCSSRules,
|
|
|
|
|
- jsEnabled: this.options.jsEnabled,
|
|
|
|
|
- removeScripts: this.options.removeScripts,
|
|
|
|
|
- saveRawPage: this.options.saveRawPage,
|
|
|
|
|
- compressHTML: this.options.compressHTML,
|
|
|
|
|
- compressCSS: this.options.compressCSS,
|
|
|
|
|
- lazyLoadImages: this.options.lazyLoadImages,
|
|
|
|
|
- framesData: this.options.framesData,
|
|
|
|
|
- maxResourceSize: this.options.maxResourceSize,
|
|
|
|
|
- maxResourceSizeEnabled: this.options.maxResourceSizeEnabled
|
|
|
|
|
- };
|
|
|
|
|
|
|
+ const options = Object.create(this.options);
|
|
|
|
|
+ options.insertSingleFileComment = false;
|
|
|
|
|
+ options.insertFaviconLink = false;
|
|
|
|
|
+ options.url = frameData.baseURI;
|
|
|
|
|
+ options.windowId = frameWindowId;
|
|
|
if (frameData.content) {
|
|
if (frameData.content) {
|
|
|
frameData.processor = new PageProcessor(options);
|
|
frameData.processor = new PageProcessor(options);
|
|
|
frameData.frameElement = frameElement;
|
|
frameData.frameElement = frameElement;
|
|
@@ -475,27 +464,15 @@ const SingleFileCore = (() => {
|
|
|
return frameData.processor.initialize();
|
|
return frameData.processor.initialize();
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
- if (frameElement.tagName == "OBJECT") {
|
|
|
|
|
- frameElement.setAttribute("data", "about:blank");
|
|
|
|
|
- } else {
|
|
|
|
|
- frameElement.setAttribute("src", "about:blank");
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ setFrameEmptySrc(frameElement);
|
|
|
if (frameData.processor) {
|
|
if (frameData.processor) {
|
|
|
const pageData = await frameData.processor.getPageData();
|
|
const pageData = await frameData.processor.getPageData();
|
|
|
- if (frameElement.tagName == "OBJECT") {
|
|
|
|
|
- frameElement.setAttribute("data", "data:text/html," + pageData.content);
|
|
|
|
|
- } else {
|
|
|
|
|
- frameElement.setAttribute("srcdoc", pageData.content);
|
|
|
|
|
- frameElement.sandbox = true;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ frameElement.setAttribute(frameElement.tagName == "OBJECT" ? "data" : "srcdoc", "data:text/html," + pageData.content);
|
|
|
|
|
+ frameElement.sandbox = true;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
- if (frameElement.tagName == "OBJECT") {
|
|
|
|
|
- frameElement.setAttribute("data", "about:blank");
|
|
|
|
|
- } else {
|
|
|
|
|
- frameElement.setAttribute("src", "about:blank");
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ setFrameEmptySrc(frameElement);
|
|
|
}
|
|
}
|
|
|
}));
|
|
}));
|
|
|
}
|
|
}
|
|
@@ -538,7 +515,7 @@ const SingleFileCore = (() => {
|
|
|
const pageData = await processor.getPageData();
|
|
const pageData = await processor.getPageData();
|
|
|
linkElement.setAttribute("href", "data:text/html," + pageData.content);
|
|
linkElement.setAttribute("href", "data:text/html," + pageData.content);
|
|
|
} else {
|
|
} else {
|
|
|
- linkElement.setAttribute("href", "about:blank");
|
|
|
|
|
|
|
+ linkElement.setAttribute("href", EMPTY_DATA_URI);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}));
|
|
}));
|