|
|
@@ -463,10 +463,19 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => {
|
|
|
util.postProcessDoc(this.doc);
|
|
|
const url = util.parseURL(this.baseURI);
|
|
|
if (this.options.insertSingleFileComment) {
|
|
|
+ const firstComment = this.doc.documentElement.firstChild;
|
|
|
+ let infobarURL = this.options.saveUrl, infobarSaveDate = this.options.saveDate;
|
|
|
+ if (firstComment.nodeType == 8 && (firstComment.textContent.includes(util.COMMENT_HEADER_LEGACY) || firstComment.textContent.includes(util.COMMENT_HEADER))) {
|
|
|
+ const info = this.doc.documentElement.firstChild.textContent.split("\n");
|
|
|
+ const [, , url, saveDate] = info;
|
|
|
+ infobarURL = url.split("url: ")[1];
|
|
|
+ infobarSaveDate = saveDate.split("saved date: ")[1];
|
|
|
+ firstComment.remove();
|
|
|
+ }
|
|
|
const infobarContent = (this.options.infobarContent || "").replace(/\\n/g, "\n").replace(/\\t/g, "\t");
|
|
|
const commentNode = this.doc.createComment("\n " + (this.options.useLegacyCommentHeader ? util.COMMENT_HEADER_LEGACY : util.COMMENT_HEADER) +
|
|
|
- " \n url: " + this.options.saveUrl +
|
|
|
- " \n saved date: " + this.options.saveDate +
|
|
|
+ " \n url: " + infobarURL +
|
|
|
+ " \n saved date: " + infobarSaveDate +
|
|
|
(infobarContent ? " \n info: " + infobarContent : "") + "\n");
|
|
|
this.doc.documentElement.insertBefore(commentNode, this.doc.documentElement.firstChild);
|
|
|
}
|