Skip to content

Commit

Permalink
fixes #26
Browse files Browse the repository at this point in the history
  • Loading branch information
bunglegrind committed Nov 28, 2024
1 parent 100a902 commit c6b9125
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 3 additions & 1 deletion web-extension/extractHtml.js
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,8 @@ chrome.runtime.onMessage.addListener(function (request, sender, sendResponse) {
"saveasebook-src",
"src"
);
const doc = new DOMParser().parseFromString(htmlContent, "text/html");
const res = new XMLSerializer().serializeToString(doc);

allImages.forEach(function (tmpImg) {
imgsPromises.push(promiseAddZip(tmpImg.originalUrl, tmpImg.filename));
Expand All @@ -529,7 +531,7 @@ chrome.runtime.onMessage.addListener(function (request, sender, sendResponse) {
styleFileContent: styleFile,
styleFileName: "style" + generateRandomNumber() + ".css",
images: extractedImages,
content: htmlContent
content: res
};
sendResponse(result);
}
Expand Down
8 changes: 6 additions & 2 deletions web-extension/saveEbook.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
var cssFileName = 'ebook.css';
var ebookTitle = null;

function filterHeader(content) {
const startTag = "<body>";
return content.substring(content.indexOf(startTag) + startTag.length);
}

chrome.runtime.onMessage.addListener((obj, sender, sendResponse) => {
if (obj.shortcut && obj.shortcut === 'build-ebook') {
buildEbook(obj.response);
Expand Down Expand Up @@ -132,8 +137,7 @@ function _buildEbook(allPages, fromMenu=false) {
'<title>' + tmpPageTitle+ '</title>' +
'<link href="../style/' + page.styleFileName + '" rel="stylesheet" type="text/css" />' +
'</head><body>' +
page.content +
'</body></html>'
filterHeader(page.content)
);
});

Expand Down

0 comments on commit c6b9125

Please sign in to comment.