single-file-core 1.4.4 → 1.4.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "single-file-core",
3
- "version": "1.4.4",
3
+ "version": "1.4.5",
4
4
  "description": "SingleFile Core",
5
5
  "author": "Gildas Lormeau",
6
6
  "license": "AGPL-3.0-or-later",
@@ -228,11 +228,13 @@ async function prependHTMLData(pageData, zipDataWriter, script, options) {
228
228
  pageContent += getHTMLStartData(pageData, options);
229
229
  }
230
230
  pageContent += "<div id=sfz-wait-message>Please wait...</div>";
231
- pageContent += "<div id=sfz-error-message><strong>Error</strong>: Cannot open the page from the filesystem.";
232
- pageContent += "<ul style='line-height:20px;'>";
233
- pageContent += "<li style='margin-bottom:10px'><strong>Chrome</strong>: Install <a href='https://chrome.google.com/webstore/detail/singlefile/mpiodijhokgodhhofbcjdecpffjipkle'>SingleFile</a> and enable the option \"Allow access to file URLs\" in the details page of the extension (chrome://extensions/?id=mpiodijhokgodhhofbcjdecpffjipkle).</li>";
234
- pageContent += "<li style='margin-bottom:10px'><strong>Microsoft Edge</strong>: Install <a href='https://microsoftedge.microsoft.com/addons/detail/singlefile/efnbkdcfmcmnhlkaijjjmhjjgladedno'>SingleFile</a> and enable the option \"Allow access to file URLs\" in the details page of the extension (edge://extensions/?id=efnbkdcfmcmnhlkaijjjmhjjgladedno).</li>";
235
- pageContent += "<li><strong>Safari</strong>: Select \"Security > Disable Local File Restrictions\" in the \"Develop > Developer settings\" menu.</li></ul></div>";
231
+ if (!options.extractDataFromPage) {
232
+ pageContent += "<div id=sfz-error-message><strong>Error</strong>: Cannot open the page from the filesystem.";
233
+ pageContent += "<ul style='line-height:20px;'>";
234
+ pageContent += "<li style='margin-bottom:10px'><strong>Chrome</strong>: Install <a href='https://chrome.google.com/webstore/detail/singlefile/mpiodijhokgodhhofbcjdecpffjipkle'>SingleFile</a> and enable the option \"Allow access to file URLs\" in the details page of the extension (chrome://extensions/?id=mpiodijhokgodhhofbcjdecpffjipkle).</li>";
235
+ pageContent += "<li style='margin-bottom:10px'><strong>Microsoft Edge</strong>: Install <a href='https://microsoftedge.microsoft.com/addons/detail/singlefile/efnbkdcfmcmnhlkaijjjmhjjgladedno'>SingleFile</a> and enable the option \"Allow access to file URLs\" in the details page of the extension (edge://extensions/?id=efnbkdcfmcmnhlkaijjjmhjjgladedno).</li>";
236
+ pageContent += "<li><strong>Safari</strong>: Select \"Security > Disable Local File Restrictions\" in the \"Develop > Developer settings\" menu.</li></ul></div>";
237
+ }
236
238
  if (options.insertTextBody) {
237
239
  const doc = (new DOMParser()).parseFromString(pageData.content, "text/html");
238
240
  doc.body.querySelectorAll("style, script, noscript").forEach(element => element.remove());
@@ -300,7 +302,8 @@ function getHTMLStartData(pageData, options) {
300
302
  pageContent += "<meta name=viewport content=" + JSON.stringify(pageData.viewport) + ">";
301
303
  }
302
304
  if (options.insertMetaCSP) {
303
- pageContent += "<meta http-equiv=content-security-policy content=\"default-src 'none'; connect-src 'self' data: blob:; font-src 'self' data: blob:; img-src 'self' data: blob:; style-src 'self' 'unsafe-inline' data: blob:; frame-src 'self' data: blob:; media-src 'self' data: blob:; script-src 'self' 'unsafe-inline' data: blob:; object-src 'self' data: blob:\">";
305
+ const cspContent = "default-src 'none';connect-src 'self' data: blob:;font-src 'self' data: blob:;img-src 'self' data: blob:;style-src 'self' 'unsafe-inline' data: blob:;frame-src 'self' data: blob:;media-src 'self' data: blob:;script-src 'self' 'unsafe-inline' data: blob:;object-src 'self' data: blob:";
306
+ pageContent += `<meta http-equiv=content-security-policy content=${JSON.stringify(cspContent)}>`;
304
307
  }
305
308
  pageContent += "<style>@keyframes display-wait-message{0%{opacity:0}100%{opacity:1}};body{color:transparent};div{color:initial}</style>";
306
309
  pageContent += "<body hidden>";