single-file-core 1.3.28 → 1.3.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/core/index.js
CHANGED
|
@@ -502,6 +502,7 @@ class Processor {
|
|
|
502
502
|
}
|
|
503
503
|
|
|
504
504
|
async getPageData() {
|
|
505
|
+
let commentText;
|
|
505
506
|
util.postProcessDoc(this.doc);
|
|
506
507
|
const url = util.parseURL(this.baseURI);
|
|
507
508
|
if (this.options.insertSingleFileComment) {
|
|
@@ -519,12 +520,11 @@ class Processor {
|
|
|
519
520
|
}
|
|
520
521
|
}
|
|
521
522
|
const infobarContent = (this.options.infobarContent || "").replace(/\\n/g, "\n").replace(/\\t/g, "\t");
|
|
522
|
-
|
|
523
|
-
"\n " + (this.options.useLegacyCommentHeader ? util.COMMENT_HEADER_LEGACY : util.COMMENT_HEADER) +
|
|
523
|
+
commentText = "\n " + (this.options.useLegacyCommentHeader ? util.COMMENT_HEADER_LEGACY : util.COMMENT_HEADER) +
|
|
524
524
|
" \n url: " + infobarURL +
|
|
525
525
|
(this.options.removeSavedDate ? " " : " \n saved date: " + infobarSaveDate) +
|
|
526
|
-
(infobarContent ? " \n info: " + infobarContent : "") + "\n"
|
|
527
|
-
);
|
|
526
|
+
(infobarContent ? " \n info: " + infobarContent : "") + "\n";
|
|
527
|
+
const commentNode = this.doc.createComment(commentText);
|
|
528
528
|
this.doc.documentElement.insertBefore(commentNode, this.doc.documentElement.firstChild);
|
|
529
529
|
}
|
|
530
530
|
const legacyInfobarElement = this.doc.querySelector("singlefile-infobar");
|
|
@@ -596,7 +596,8 @@ class Processor {
|
|
|
596
596
|
title: this.options.title || (this.baseURI && matchTitle ? matchTitle[1] : url.hostname ? url.hostname : ""),
|
|
597
597
|
filename,
|
|
598
598
|
mimeType,
|
|
599
|
-
content
|
|
599
|
+
content,
|
|
600
|
+
comment: commentText,
|
|
600
601
|
}, additionalData);
|
|
601
602
|
if (this.options.addProof) {
|
|
602
603
|
pageData.hash = await util.digest("SHA-256", content);
|
package/package.json
CHANGED
|
@@ -27,7 +27,7 @@ export {
|
|
|
27
27
|
display
|
|
28
28
|
};
|
|
29
29
|
|
|
30
|
-
async function display(document, docContent, { disableFramePointerEvents }) {
|
|
30
|
+
async function display(document, docContent, { disableFramePointerEvents } = {}) {
|
|
31
31
|
docContent = docContent.replace(/<noscript/gi, "<template disabled-noscript");
|
|
32
32
|
docContent = docContent.replaceAll(/<\/noscript/gi, "</template");
|
|
33
33
|
const doc = (new DOMParser()).parseFromString(docContent, "text/html");
|
|
@@ -285,7 +285,10 @@ function getHTMLStartData(pageData, options) {
|
|
|
285
285
|
}
|
|
286
286
|
const charset = options.extractDataFromPage ? "windows-1252" : "utf-8";
|
|
287
287
|
const title = options.extractDataFromPage ? "" : getPageTitle(pageData);
|
|
288
|
-
pageContent +=
|
|
288
|
+
pageContent += options.embeddedImage ? "" : pageData.doctype;
|
|
289
|
+
pageContent += "<html data-sfz>";
|
|
290
|
+
pageContent += pageData.comment && !options.embeddedImage ? "<!--" + pageData.comment + "-->" : "";
|
|
291
|
+
pageContent += "<meta charset=" + charset + "><title>" + title + "</title>";
|
|
289
292
|
if (options.insertCanonicalLink) {
|
|
290
293
|
pageContent += "<link rel=canonical href=\"" + options.url + "\">";
|
|
291
294
|
}
|
package/single-file.js
CHANGED
|
@@ -117,7 +117,8 @@ async function getPageData(options = {}, initOptions, doc = globalThis.document,
|
|
|
117
117
|
insertMetaNoIndex: options.insertMetaNoIndex,
|
|
118
118
|
insertMetaCSP: options.insertMetaCSP,
|
|
119
119
|
password: options.password,
|
|
120
|
-
zipScript: options.zipScript
|
|
120
|
+
zipScript: options.zipScript,
|
|
121
|
+
embeddedImage: options.embeddedImage
|
|
121
122
|
});
|
|
122
123
|
delete pageData.resources;
|
|
123
124
|
const reader = new globalThis.FileReader();
|