|
|
@@ -78,6 +78,8 @@ this.SingleFileCore = this.SingleFileCore || (() => {
|
|
|
this.options.url = this.options.url || this.options.doc.location.href;
|
|
|
this.processor = new DOMProcessor(options);
|
|
|
if (this.options.doc) {
|
|
|
+ this.options.canvasData = this.processor.getCanvasData();
|
|
|
+ this.options.emptyStyleRulesText = this.processor.getEmptyStyleRulesText();
|
|
|
this.processor.fixInlineScripts();
|
|
|
this.processor.disableNoscriptElements();
|
|
|
this.processor.hideNonMetadataContents();
|
|
|
@@ -396,6 +398,28 @@ this.SingleFileCore = this.SingleFileCore || (() => {
|
|
|
this.options.doc.querySelectorAll("[" + WIN_ID_ATTRIBUTE_NAME + "]").forEach(element => element.removeAttribute(WIN_ID_ATTRIBUTE_NAME));
|
|
|
}
|
|
|
|
|
|
+ getEmptyStyleRulesText() {
|
|
|
+ const textData = [];
|
|
|
+ this.options.doc.querySelectorAll("style").forEach(styleElement => {
|
|
|
+ if (!styleElement.textContent) {
|
|
|
+ textData.push(Array.from(styleElement.sheet.cssRules).map(rule => rule.cssText).join("\n"));
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return textData;
|
|
|
+ }
|
|
|
+
|
|
|
+ getCanvasData() {
|
|
|
+ const canvasData = [];
|
|
|
+ this.options.doc.querySelectorAll("canvas").forEach(canvasElement => {
|
|
|
+ try {
|
|
|
+ canvasData.push({ dataURI: canvasElement.toDataURL("image/png", ""), width: canvasElement.clientWidth, height: canvasElement.clientHeight });
|
|
|
+ } catch (error) {
|
|
|
+ canvasData.push(null);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return canvasData;
|
|
|
+ }
|
|
|
+
|
|
|
enableDisabledNoscriptTags(noscriptTags) {
|
|
|
noscriptTags.forEach(element => {
|
|
|
const noscriptElement = this.options.doc.createElement("noscript");
|