|
|
@@ -25,6 +25,7 @@
|
|
|
|
|
|
const fs = require("fs");
|
|
|
const path = require("path");
|
|
|
+const scripts = require("./back-ends/common/scripts.js");
|
|
|
const VALID_URL_TEST = /^(https?|file):\/\//;
|
|
|
|
|
|
const DEFAULT_OPTIONS = {
|
|
|
@@ -251,6 +252,9 @@ async function capturePage(options) {
|
|
|
try {
|
|
|
let filename;
|
|
|
const pageData = await backend.getPageData(options);
|
|
|
+ if (options.includeInfobar) {
|
|
|
+ await includeInfobarScript(pageData);
|
|
|
+ }
|
|
|
if (options.output) {
|
|
|
filename = getFilename(options.output, options);
|
|
|
} else if (options.dumpContent) {
|
|
|
@@ -313,3 +317,14 @@ function getFilename(filename, options, index = 1) {
|
|
|
function escapeRegExp(string) {
|
|
|
return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
|
}
|
|
|
+
|
|
|
+async function includeInfobarScript(pageData) {
|
|
|
+ let infobarContent = await scripts.getInfobarScript();
|
|
|
+ let lastInfobarContent;
|
|
|
+ while (lastInfobarContent != infobarContent) {
|
|
|
+ lastInfobarContent = infobarContent;
|
|
|
+ infobarContent = infobarContent.replace(/\/\*(.|\n)*?\*\//, "");
|
|
|
+ }
|
|
|
+ infobarContent = infobarContent.replace(/\t+/g, " ").replace(/\nthis\.[^(]*/gi, "\n").replace(/\n+/g, "");
|
|
|
+ pageData.content += "<script>document.currentScript.remove();" + infobarContent + "</script>";
|
|
|
+}
|