single-file-core 1.8.1 → 1.9.0

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.
Files changed (2) hide show
  1. package/core/index.js +10 -2
  2. package/package.json +1 -1
package/core/index.js CHANGED
@@ -166,7 +166,8 @@ const STAGES = [{
166
166
  { action: "insertVariables" },
167
167
  { action: "removeEmptyMediaAutoplay" },
168
168
  { option: "compressHTML", action: "compressHTML" },
169
- { action: "cleanupPage" }
169
+ { action: "cleanupPage" },
170
+ { option: "embeddedScript", action: "insertEmbeddedScript" }
170
171
  ],
171
172
  parallel: [
172
173
  { option: "readMaffMetadata", action: "readMAFFMetaData" },
@@ -509,7 +510,7 @@ const ORDER_DEPENDENT_RULE = /@(layer|import)\b/i;
509
510
  const MANIFEST_TOP_WINDOW_ID = "0";
510
511
  const WINDOW_ID_SEPARATOR = ".";
511
512
  const MANIFEST_EXCLUDED_OPTION_NAMES = ["rootDocument", "saveFilenameTemplateData", "omitReferrerInTemplateData", "manifest"];
512
- const MANIFEST_STRING_OPTION_NAMES = ["customStylesheet", "filenameTemplate"];
513
+ const MANIFEST_STRING_OPTION_NAMES = ["customStylesheet", "embeddedScript", "filenameTemplate"];
513
514
 
514
515
  class Processor {
515
516
  constructor(options, processorHelper, batchRequest) {
@@ -1557,6 +1558,7 @@ class Processor {
1557
1558
  options.saveFavicon = false;
1558
1559
  options.includeInfobar = false;
1559
1560
  options.saveFilenameTemplateData = false;
1561
+ options.embeddedScript = null;
1560
1562
  options.selected = false;
1561
1563
  options.embeddedImage = null;
1562
1564
  options.embeddedPdf = null;
@@ -1865,6 +1867,12 @@ class Processor {
1865
1867
  }
1866
1868
  }
1867
1869
 
1870
+ insertEmbeddedScript() {
1871
+ const scriptElement = this.doc.createElement("script");
1872
+ scriptElement.textContent = this.options.embeddedScript;
1873
+ (this.doc.body || this.doc.documentElement).appendChild(scriptElement);
1874
+ }
1875
+
1868
1876
  resetZoomLevel() {
1869
1877
  const transform = this.doc.documentElement.style.getPropertyValue("-sf-transform");
1870
1878
  const transformPriority = this.doc.documentElement.style.getPropertyPriority("-sf-transform");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "single-file-core",
3
- "version": "1.8.1",
3
+ "version": "1.9.0",
4
4
  "description": "SingleFile Core",
5
5
  "author": "Gildas Lormeau",
6
6
  "license": "AGPL-3.0-or-later",