From fba172b027530849c60787f95542f6762aa9a688 Mon Sep 17 00:00:00 2001 From: Ilian Sapundshiev Date: Thu, 11 Jul 2024 17:17:46 +0200 Subject: [PATCH] released 4.0.6, removing save selection as html functionality, fixing utf8 recognition --- src/static/popup.html | 4 +- src/ui/popup.js | 91 ++++++++++++++++++++++--------------------- 2 files changed, 48 insertions(+), 47 deletions(-) diff --git a/src/static/popup.html b/src/static/popup.html index 9b46f4a..e9a4bed 100644 --- a/src/static/popup.html +++ b/src/static/popup.html @@ -132,7 +132,7 @@ -
+
{ - const htmlBlob = new Blob([convertedHTML], { + console.log(convertedHTML); + var BOM = new Uint8Array([0xef, 0xbb, 0xbf]); + const htmlBlob = new Blob([BOM, convertedHTML], { type: "text/html;charset=utf-8", }); saveAsFile(htmlBlob, generateFileName("html")); @@ -312,30 +312,30 @@ function saveWholePageAsHTML() { }); } -function saveSelectionAsHTML() { - const saveSelectionAsHtmlSpinner = document.querySelector( - "#saveSelectionAsHtmlSpinner" - ); - saveSelectionAsHtmlSpinner.classList.remove("d-none"); - if (!htmlSelection || htmlSelection.length < 1) { - alert("No content selected...."); - saveSelectionAsHtmlSpinner.classList.add("d-none"); - return; - } - prepareContentPromise(htmlSelection) - .then((cleanenHTML) => { - const htmlBlob = new Blob([cleanenHTML], { - type: "text/html;charset=utf-8", - }); - saveAsFile(htmlBlob, generateFileName("html")); - saveSelectionAsHtmlSpinner.classList.add("d-none"); - }) - .catch((err) => { - alert("Error by preparing the HTML content..."); - // location.reload(); - console.warn("Error handling html content " + err); - }); -} +// function saveSelectionAsHTML() { +// const saveSelectionAsHtmlSpinner = document.querySelector( +// "#saveSelectionAsHtmlSpinner" +// ); +// saveSelectionAsHtmlSpinner.classList.remove("d-none"); +// if (!htmlSelection || htmlSelection.length < 1) { +// alert("No content selected...."); +// saveSelectionAsHtmlSpinner.classList.add("d-none"); +// return; +// } +// prepareContentPromise(htmlSelection) +// .then((cleanenHTML) => { +// const htmlBlob = new Blob([cleanenHTML], { +// type: "text/html;charset=utf-8", +// }); +// saveAsFile(htmlBlob, generateFileName("html")); +// saveSelectionAsHtmlSpinner.classList.add("d-none"); +// }) +// .catch((err) => { +// alert("Error by preparing the HTML content..."); +// // location.reload(); +// console.warn("Error handling html content " + err); +// }); +// } function saveScreenshot() { const saveScreenshotSpinner = document.querySelector( @@ -429,6 +429,7 @@ function updatePreviewArea(htmlContent) { const cleanedPath = pathBaseURL.origin + pathBaseURL.pathname; for (const img of allImages) { + img.style.maxWidth = "100%"; const imgSrc = img.getAttribute("src"); // console.log(imgSrc); // img.setAttribute("width", img.getAttribute("naturalWidth"));