single-file-core 1.2.41 → 1.2.421

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/helper.js CHANGED
@@ -61,6 +61,7 @@ const INVALID_ELEMENT_ATTRIBUTE_NAME = "data-" + SINGLE_FILE_PREFIX + "invalid-e
61
61
  const ASYNC_SCRIPT_ATTRIBUTE_NAME = "data-" + SINGLE_FILE_PREFIX + "async-script";
62
62
  const FLOW_ELEMENTS_SELECTOR = "*:not(base):not(link):not(meta):not(noscript):not(script):not(style):not(template):not(title)";
63
63
  const KEPT_TAG_NAMES = ["NOSCRIPT", "DISABLED-NOSCRIPT", "META", "LINK", "STYLE", "TITLE", "TEMPLATE", "SOURCE", "OBJECT", "SCRIPT", "HEAD", "BODY"];
64
+ const IGNORED_TAG_NAMES = ["SCRIPT", "NOSCRIPT", "META", "LINK", "TEMPLATE"];
64
65
  const REGEXP_SIMPLE_QUOTES_STRING = /^'(.*?)'$/;
65
66
  const REGEXP_DOUBLE_QUOTES_STRING = /^"(.*?)"$/;
66
67
  const FONT_WEIGHTS = {
@@ -219,7 +220,7 @@ function getElementsInfo(win, doc, element, options, data = { usedFonts: new Map
219
220
  elementKept = ((ascendantHidden || element.closest("html > head")) && KEPT_TAG_NAMES.includes(element.tagName.toUpperCase())) || element.closest("details");
220
221
  if (!elementKept) {
221
222
  elementHidden = ascendantHidden || testHiddenElement(element, computedStyle);
222
- if (elementHidden) {
223
+ if (elementHidden && !IGNORED_TAG_NAMES.includes(element.tagName.toUpperCase())) {
223
224
  element.setAttribute(HIDDEN_CONTENT_ATTRIBUTE_NAME, "");
224
225
  data.markedElements.push(element);
225
226
  }
package/core/index.js CHANGED
@@ -503,7 +503,7 @@ class Processor {
503
503
  const info = this.doc.documentElement.firstChild.textContent.split("\n");
504
504
  try {
505
505
  const [, , url, saveDate] = info;
506
- infobarURL = url.split("url: ")[1];
506
+ infobarURL = url.split("url: ")[1].trim();
507
507
  infobarSaveDate = saveDate.split("saved date: ")[1];
508
508
  firstComment.remove();
509
509
  } catch (error) {
@@ -651,34 +651,33 @@ class Processor {
651
651
  }
652
652
 
653
653
  saveFilenameTemplateData() {
654
- const existingScript = this.doc.querySelector("script[" + SCRIPT_OPTIONS + "][type=\"application/json\"]");
655
- if (existingScript) {
656
- existingScript.remove();
657
- }
658
- const optionsElement = this.doc.createElement("script");
659
- optionsElement.type = "application/json";
660
- optionsElement.setAttribute(SCRIPT_OPTIONS, "");
661
- optionsElement.textContent = JSON.stringify({
662
- saveUrl: this.options.url,
663
- saveDate: this.options.saveDate.getTime(),
664
- visitDate: this.options.visitDate.getTime(),
665
- filenameTemplate: this.options.filenameTemplate,
666
- filenameReplacedCharacters: this.options.filenameReplacedCharacters,
667
- filenameReplacementCharacter: this.options.filenameReplacementCharacter,
668
- filenameMaxLengthUnit: this.options.filenameMaxLengthUnit,
669
- filenameMaxLength: this.options.filenameMaxLength,
670
- replaceEmojisInFilename: this.options.replaceEmojisInFilename,
671
- compressContent: this.options.compressContent,
672
- selfExtractingArchive: this.options.selfExtractingArchive,
673
- extractDataFromPage: this.options.extractDataFromPage,
674
- referrer: this.options.referrer,
675
- title: this.options.title,
676
- info: this.options.info
677
- });
678
- if (this.doc.body.firstChild) {
679
- this.doc.body.insertBefore(optionsElement, this.doc.body.firstChild);
680
- } else {
681
- this.doc.body.appendChild(optionsElement);
654
+ const optionsElement = this.doc.querySelector("script[" + SCRIPT_OPTIONS + "][type=\"application/json\"]");
655
+ if (!optionsElement) {
656
+ const optionsElement = this.doc.createElement("script");
657
+ optionsElement.type = "application/json";
658
+ optionsElement.setAttribute(SCRIPT_OPTIONS, "");
659
+ optionsElement.textContent = JSON.stringify({
660
+ saveUrl: this.options.url,
661
+ saveDate: this.options.saveDate.getTime(),
662
+ visitDate: this.options.visitDate.getTime(),
663
+ filenameTemplate: this.options.filenameTemplate,
664
+ filenameReplacedCharacters: this.options.filenameReplacedCharacters,
665
+ filenameReplacementCharacter: this.options.filenameReplacementCharacter,
666
+ filenameMaxLengthUnit: this.options.filenameMaxLengthUnit,
667
+ filenameMaxLength: this.options.filenameMaxLength,
668
+ replaceEmojisInFilename: this.options.replaceEmojisInFilename,
669
+ compressContent: this.options.compressContent,
670
+ selfExtractingArchive: this.options.selfExtractingArchive,
671
+ extractDataFromPage: this.options.extractDataFromPage,
672
+ referrer: this.options.referrer,
673
+ title: this.options.title,
674
+ info: this.options.info
675
+ });
676
+ if (this.doc.body.firstChild) {
677
+ this.doc.body.insertBefore(optionsElement, this.doc.body.firstChild);
678
+ } else {
679
+ this.doc.body.appendChild(optionsElement);
680
+ }
682
681
  }
683
682
  }
684
683
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "single-file-core",
3
- "version": "1.2.41",
3
+ "version": "1.2.421",
4
4
  "description": "SingleFile Core",
5
5
  "author": "Gildas Lormeau",
6
6
  "license": "AGPL-3.0-or-later",