alexadam / save-as-ebook Goto Github PK
View Code? Open in Web Editor NEWSave a web page/selection as an eBook (.epub format) - a Chrome/Firefox/Opera Web Extension
License: MIT License
Save a web page/selection as an eBook (.epub format) - a Chrome/Firefox/Opera Web Extension
License: MIT License
Save-as-ebook is good at capturing everything in the page indiscriminately, which is useful because capturing everything is better than not capturing the needed part of the page. But this also makes it necessary to clean the generated epub of the unnecessary details afterwards.
Adding the ability to apply regular expression replacements on the capture, based on some site rules would significantly if not completely reduce the need to separately clean the epub afterwards.
Also as I mentioned before it would also help editing the epub if the names of the files inside the created epub are human readable.
This plugin usually captures some unneeded elements for me so far. For example it works terrible with scribblehub. If there is even one comment in the comment section the main content is completely ignored and only the comments are captured. When that happens epub starts with the string "Error: Parse Error:".
Even when the main content is captured there are some unneeded elements capture both before and after the necessary content. It would be nice if we can specify which elements are going to be captured or not, preferably by using Xpath expression of the needed elements.
The add-on doesn't handle special characters properly. I was testing on a page whose title contains '&' character which was not escaped/converted. Therefore, generated xml files (content.opf, toc.ncx etc.) have become non-persible. Tested on Firefox 55 with official add-on.
Thanks to the 'Custom Style' feature, I can export just the portion of a page I need. However, it is not applied automatically and I have to click on 'Apply' every time for each page. This is really inconvenient and tedious when I'm exporting multiple pages (as chapters). I think custom styles should be applied by default, at least for pages that match the regex.
Alternatively, adding a check box similar to 'Include Style' should do the trick.
Trying to saving https://www.wired.it/attualita/tech/2019/03/19/singapore-citta-intelligente/
Extension freezes and icon show Busy status even after browser restart.
How can I clean up state?
Thanks in advance
First of all, great project! I'd love to use the Firefox extension, but I couldn't get over the number (and magnitude) of permissions requested. Can see why some of these are necessary, but still, "access your data for all websites" seems scary.
I'm not familiar with building browser extensions, so I apologize in advance. Are all these permissions necessary?
If I convert the following url to a epub (save page):
https://overreacted.io/making-setinterval-declarative-with-react-hooks/
with the following custom css rules:
header h3,
.react-toggle,
main article header p,
footer,
aside
{display: none!important;}
body div div div div
{
max-width: 90%!important;
}
the display:block in class .gatsby-highlight-code-line is not present in the epub. leading to issues in visualization (as example please notice the first code box when "Your custom logic here" is written).
I'm using Firefox 90.0.2 on Windows.
In
save-as-ebook/web-extension/extractHtml.js
Line 120 in 12a4cbb
you're converting iframes to divs. The problem is, if an iframe has a style node, you're applying this style to the whole page.
Similar to #50, borders are not present in the tables (and I suppose in every other place).
Save the following page:
https://dev.mysql.com/doc/refman/8.0/en/innodb-locking.html
with the custom CSS rules:
header,
#docs-sidebar-toc,
#docs-version-nav,
#docs-breadcrumbs,
#docs-in-page-nav-container,
footer
{
display: none!important;
}
.has-toc {
margin-left: 0!important;
border-left: none!important;
}
and check the borders of the first table.
I'm using Firefox on Windows, I haven't tested on Chrome.
The reason is the "border" property: in Firefox it's an empty string and when you grab its content in
save-as-ebook/web-extension/extractHtml.js
Line 329 in 12a4cbb
you get nothing.
I've locally fixed the issue by changing the content of the supportedCss array in
const supportedCss = [
'background-color',
'border-top-width',
'border-top-style',
'border-top-color',
'border-bottom-width',
'border-bottom-style',
'border-bottom-color',
'border-left-width',
'border-left-style',
'border-left-color',
'border-right-width',
'border-right-style',
'border-right-color',
'border-collapse',
'color',
'font',
'line-height',
'list-style',
'padding',
'text-align',
'display'
];
appreciate very much if you could get a thunderbird extension please
Would it be possible to add a button to change the page direction?
This is useful for Japanese novels and books, where the text is normally read vertically right to left, with pages being turned from right to left.
This requires adding a parameter to the spine tag in contents.opf (around line 163 of saveEbook.js)
The default spine is defined as:
'<spine toc="ncx">'
A right-to-left spine is defined as:
'<spine toc="ncx" page-progression-direction="rtl">'
I have attempted implementing a button for the functionality but ended up breaking the locally unpacked extension for Chrome.
Some pages use double line breaks (<br>, <br />) instead of paragraphs. During conversion, these tags are trimmed (I guess), which causes the whole book/chapter to be a single paragraph.
No idea what the problem is, but just to let you know I've tried to install as a Firefox add-on a number of times without success.
Clicking 'Add to Firefox' on https://addons.mozilla.org/en-US/firefox/addon/saveasebook/ opens a dialogue that shows it downloads fully very quickly but doesn't seem to install.
On 'about:addons' it shows as 'Downloading' but doesn't complete and can't be cancelled without closing the browser completely.
The manual install works fine.
(Really useful add-on - thanks!)
The attributes writing-mode and -epub-writing-mode are filtered out by extractHtml.js in supportedCss. Adding them to the array lets them through to the combined css. However, there is still an unexpected behavior.
Adding the following css snippet to the custom styles:
html { -epub-writing-mode: vertical-rl; writing-mode: vertical-rl; }
The resulting css in the epub is:
.vj0 {background-color:rgba(0, 0, 0, 0);border:0px none rgb(0, 0, 0);color:rgb(0, 0, 0);font:16px / 25.6px "Times New Roman";line-height:25.6px;list-style:outside none disc;padding:0px;text-align:start;writing-mode:vertical-rl;} .wY1 {background-color:rgba(0, 0, 0, 0);border:0px none rgb(0, 0, 0);color:rgb(0, 0, 0);font:700 32px / 51.2px "Times New Roman";line-height:51.2px;list-style:outside none disc;padding:0px;text-align:start;writing-mode:vertical-rl;} .zV2 {background-color:rgba(0, 0, 0, 0);border:0px none rgb(0, 0, 0);color:rgb(0, 0, 0);font:700 24px / 38.4px "Times New Roman";line-height:38.4px;list-style:outside none disc;padding:0px;text-align:start;writing-mode:vertical-rl;} .mv349 {background-color:rgba(0, 0, 0, 0);border:0px none rgb(0, 0, 0);color:rgb(0, 0, 0);font:700 20px / 25.6px "Times New Roman";line-height:25.6px;list-style:outside none disc;padding:0px;text-align:start;writing-mode:vertical-rl;} .RM354 {background-color:rgba(0, 0, 0, 0);border:0px none rgb(0, 0, 0);color:rgb(0, 0, 0);font:700 18px / 25.6px "Times New Roman";line-height:25.6px;list-style:outside none disc;padding:0px;text-align:start;writing-mode:vertical-rl;} .Jk357 {background-color:rgba(0, 0, 0, 0);border:0px none rgb(0, 0, 0);color:rgb(0, 0, 0);font:16px / 16px "Times New Roman";line-height:16px;list-style:outside none disc;padding:0px;text-align:start;writing-mode:vertical-rl;} .lL360 {background-color:rgba(0, 0, 0, 0);border:0px none rgb(0, 0, 0);color:rgb(0, 0, 0);font:8px / 4px "Times New Roman";line-height:4px;list-style:outside none disc;padding:0px;text-align:start;writing-mode:vertical-rl;} .ow8104 {background-color:rgba(0, 0, 0, 0);border:0px none rgb(0, 0, 0);color:rgb(0, 0, 0);font:13.3333px / 25.6px "Times New Roman";line-height:25.6px;list-style:outside none disc;padding:0px;text-align:start;writing-mode:vertical-rl;} .xU24984 {background-color:rgba(0, 0, 0, 0);border:1px inset rgb(0, 0, 0);color:rgb(0, 0, 0);font:16px / 25.6px "Times New Roman";line-height:25.6px;list-style:outside none disc;padding:0px;text-align:start;writing-mode:vertical-rl;} .Hj24998 {background-color:rgba(0, 0, 0, 0);border:0px none rgb(0, 0, 238);color:rgb(0, 0, 238);font:16px / 25.6px "Times New Roman";line-height:25.6px;list-style:outside none disc;padding:0px;text-align:start;writing-mode:vertical-rl;} .Zr25006 {background-color:rgba(0, 0, 0, 0);border:0px none rgb(0, 0, 0);color:rgb(0, 0, 0);font:16px / 25.6px "Times New Roman";line-height:25.6px;list-style:outside none disc;padding:40px 0px 0px;text-align:start;writing-mode:vertical-rl;} .QM25007 {background-color:rgba(0, 0, 0, 0);border:0px none rgb(0, 0, 0);color:rgb(0, 0, 0);font:16px / 25.6px "Times New Roman";line-height:25.6px;list-style:outside none disc;padding:0px;text-align:left;writing-mode:vertical-rl;}
The -epub-writing-mode somehow was still filtered out. This renders the whole book wrong, somehow collapsing a 56 chapters book into a 4 pages book.
Manually adding back the -epub-writing-mode snippet to the top of that generated css fixes the book rendering.
html { -epub-writing-mode: vertical-rl; } ...
And yet it mangles them anyway by removing the "1201841h.html" for:
http://gutenberg.net.au/ebooks12/1201841h.html
Hmmm!?
This is a good text site for ebooks that are only available as web pages.
Kindest Regards.
This is probably an edge case but I had a few pages opened in tabs, then added the extension.
It fails with no obvious message in the UI but this in the console:
Unchecked runtime.lastError: Could not establish connection. Receiving end does not exist.
I needed to reload the pages before it worked. I don't know if you can code around this but maybe you can document it?
Today I wasted an hour trying to make a large ePub from 25+ favourite Medium.com articles on UX design.
Once I was done adding chapters I rendered the ePub.
It downloaded the hefty 114Mb ePub and cleared the Chapter Queue, yet the generated ePub wouldn't successfully open, and triggered a "corrupt!" warning in iBooks.
I tried converting it to a PDF with online tools but they all say the filesize is too big.
To improve the overal experience, consider adding Projects/sessions the user can come back to, save mid-session, or edit/add content to at later time.
Alternatively it would also be an improvement if the "project" would at least get saved locally, so that a refresh (accidental, forced or intentional) won't mean losing your progress.
this is just a tip, for future releases.
The identifier
element in the OEBPS/content.opf
file of saved EPUB files has identical isbn
value:
<dc:identifier id="db-id">isbn</dc:identifier>
So, adding a newly saved EPUB file to my foliate library replaces the old one.
For the time being, to work around the issue, I have to generate UUID manually and use it instead of isbn
for every file, which I would like to avoid.
Your extension is awesome for public schools and teacher. May I help you to translate it in french for free ? I'm in charge of prospective in french ministry of education. Regards.
Saver prepends base URL to all relative URLs, even to in-page ones, i. e. a link like <a href="#ref1">
becomes <a href="https://example.org/article#ref1">
.
This seems to be easily fixable for single-page epubs, yet it would be very nice if cross-page links between chapters saved in a single epub from different pages would be uniquified and converted to relatives too.
The goal of feature 'Include custom style' is to save only the relevant content without much hassle.
Sadly, it works only on predefined sites / is work to configure for each new site.
The solution: Use the browsers 'reading mode' output instead.
I'd like to be able to convert a page or selection as multiple chapters based on the location of H1, H2, etc tags, using the plain text between the opening and closing of a tag as the chapter name.
As an example, I just converted the Lua 5.3 Reference Manual to an eBook. It was a tedious process to manually select each chapter and capture it individually, then go back to edit the chapters to correct their titles. It would have been so much easier to just capture the page and have this extension be able to generate the chapters from the H1 and H2 tags on the captured page.
Hi,
Love your addon. I sometimes use it for 20+ tabs in a row and it would be really helpful if i could set a keyboard shortcut for "Add Page as Chapter", but I think it might be useful for every action.
Thanks for the great extension.
It would be really helpful to be able to select a set of links from a page and add them all as chapters. I read a lot of Fan-Fiction and it would make life easyier when adding 20 or 30 pages to an ebook if I could simply select the all the chapter links and add them as chapters.
More often than not I use save-as-ebook to capture a story that has multiple chapters. So it would be awesome if this feature is added.
Currently there is one style for everything. Changing it manually can be a pain when switching between sites and most will have a desired configuration.
I would be useful to have a way to select the configuration for a specific website. Pattern match is one way but would be confusing to most users. A simple option in the pulldown menu to switch from the default to a specific configuration would be useful. At this point it would be for the Style but adding rules or other features would make the number of settings more complex but more useful in the long run.
Check out the issue "Rules for captured content" regarding the reference to Rules in this issue.
It would be useful to have an option to include the URL of the page being captured in the epub and possibly the table of contents for multiple page documents. This could be a toggle per page with a global default. This is very handy tracking where content was obtained and it is useful when doing research where attribution or linking to a source is necessary.
The URL would be included in the page above or below the title.
Additional items that might included are:
Hello,
Do you know that Save as eBook was removed from Firefox Add-ons. If you are aware of that do you know why Mozilla removed your extension from its store?
Regards
When the same image is repeated several times in the webpage this plugin downloads&adds the image each time as a different image (saves it under a different name). It would be more elegant&efficient if it only downloaded the same image once!
Empty style sheets should be deleted!
Also you should change the way the files are renamed inside the epub. It's best if you keep these names independent from the source files. Something like,
(a constant for given file type + index value).extension
would look better.
Thanks for the amazing plugin. I have plenty of uses with it.
Ok, another one:
page (not only this one...):
https://developer.wordpress.org/plugins/plugin-basics/determining-plugin-and-content-directories/
custom style:
#wpadminbar {
display:none;
}
#wporg-header {
display:none;
}
header {
display:none;
}
#secondary {
display:none;
}
#wporg-footer {
display:none;
}
.breadcrumbs {
display:none;
}
.nav-links {
display:none;
}
.table-of-contents {
display:none;
}
.toc-jump {
display:none;
}
#content {
max-width:100%!important;
}
.screen-reader-text {
display:none;
}
In the epub at random I see some of the html classes/ids that I set to display:none (#wporg-header, #wporg-footer).
I've observed that in the HTML code of the preview shown by the browser (with alt+shift+1 for instance) the classes can be hidden or absent at all, in the former case the epub will show the aforementioned issue, in the latter the epub will be correctly displayed.
I've experienced this issue both with the latest release and with the master branch.
Hello,
I tried to save a single page (this article) using 'Save Page' command and the result was horrible, I would say that the generated EPUB file is unusable.
Screens:
For me such EPUB files are unreadable.
I am using Save as eBook version 1.3.5 with Cent Browser (Chromium-based) version 4.1.7.182 on Windows 8.
I hope that this extension is still in development and and new releases would fix such issues.
Regards
It's too long. I would prefer to just have the regular underline, or whatever is the actual style. It would also be good if there was an option to not include the links in the epub at all.
Superb extension -- thankyou very much.
To access my chapters I needed to login (proxy). Now all the embedded links (there are 100s) have the proxy rather than link to the correct ebook page/section. Is this easy to fix? e.g. footnotes, author index, subject index, references etc etc..
Other than that, the EPUB is a brilliant result for my 16 chapters, 5 appendix.
This is the 5th tool I have tried and only one that grabbed ALL the content.
Done successfully
[Environment: Chrome Extension on Cataliana]
[Extension settings used: selection, CSS settings checkmark on)
Workflow
1 Opened each chapter into a tab, then for each tab, Selected content on page
2 Using "Save as ebook" Extension, save each "selection" of page as chapter
3 edit chapters, reviewed to make sure none missing. Had missed chapter 4. so re did it (took a bit for the chapter I missed to appear under edit chapter. It appeared after I made sure all tabs that were showing edit chapter were closed.
4 added Chapter Numbers as this was not on source to listing of chapters
5 generate ebook
Latex formulas result in giant height and width images in the output epub. (For instance try to convert this equation). When I convert with dotepub they are slightly large but better.
Saving several different pages with "Save Page" on some sites results in the EPUB files with identical meaningless titles, so I have to edit metadata manually by defining the correct title, adding the author and cover. Only after that can I add the EPUB files to my library. Therefore, the suggestion is to add the ability to define the following metadata before/on saving:
I'm not able to save a page or a selection when i'm in Reader View on Firefox.
OS : Ubuntu 16.04.2
Firefox : 53.0.3 (64bits)
Save As eBook : 1.1
This extension strips out non-compliant tags such as <br> and <hr>, but it would be far superior if instead of doing that it would convert them to <br/> and <hr/> since those work just fine.
I'm trying to convert the Wordpress Plugin Handbook in epub.
I'm noticing several issues, I'm currently investigating on the causes.
I set a custom style with the following rules:
#wpadminbar {
display:none;
}
#wporg-header {
display:none;
}
header {
display:none;
}
#secondary {
display:none;
}
#wporg-footer {
display:none;
}
.breadcrumbs {
display:none;
}
.nav-links {
display:none;
}
.table-of-contents {
display:none;
}
.toc-jump {
display:none;
}
#content {
max-width:100%!important;
}
.screen-reader-text {
display:none;
}
But if I convert this page:
https://developer.wordpress.org/plugins/plugin-basics/determining-plugin-and-content-directories/
the br inside the pre tags are removed showing all the content in the same line...
For example, an epub generated from this page only gets the header and the last page:
http://regiment.ru/Lib/C/172.htm
Also the header and the text on the last page stretch off the right side of the screen.
Running through Calibre, and converting to mobi, the language support issues leave it unreadable on the Kindle 2, but show much more text there.
Running through Calibre, converting to mobi, and coverting back to epub gives 4 pages on the Story Hd, still missing most of the text, and still stretching off the right side.
Check out GrabMyBooks rules and rule editor. It essentially does a selection based on rules. The interactive rule creation is impressive.
If you try to convert a Japanese webpage containing ruby tags, the rb tags are ignored by the parser.
<ruby><rb>私</rb><rp>(</rp><rt>わたくし</rt><rp>)</rp></ruby>
gets saved as
<ruby class="MG357"><rt class="WF360">わたくし</rt></ruby>
As a result, you have the ruby furigana but are missing the kanji in the epub file.
Expected output:
私
Real output:
This is caused by line 15 of extractHtml.js:
'dfn', 'em', 'i', 'img', 'kbd', 'mark', 'q', 'rp', 'rt', 'rtc', 'ruby', 's', 'samp', 'small', 'span',
Adding the rb tag solves the issue:
'dfn', 'em', 'i', 'img', 'kbd', 'mark', 'q', 'rb', 'rp', 'rt', 'rtc', 'ruby', 's', 'samp', 'small', 'span',
I tried to convert a web page and got parse error. I added a html validator to check the web site and that suggested that the problem might be <o:p></o:p> tags. These are not standard tags but are added by MS word (typical!). I saved the web page and stripped <o:p></o:p> and then tried again with the local file. This time there was no parse error. Hence it looks like the problem is MS, as usual. Perhaps the fix would be to ignore unknown tags rather than throwing an error.
A complete editor would be useful but probably very time consuming to construct. Integration with an editor like Sigil (https://github.com/Sigil-Ebook/Sigil) could be problematic.
In lieu of these, an option for page annotation would be handy. This would simply be a text box where arbitrary text could be added when a page was captured. This would allow notes to be included and possibly edited later using an ebook editor. It could be included part of the "Add an option to include extra info like the URL of a page" issue solution. A CSS style would be useful so the text could be made to stand out when displayed. This annotation would likely be placed at the start of the document but a header and footer version might be useful or a header/footer designation for a single entry.
The following web page would generate "gibberish" epub:
http://ned.ipac.caltech.edu/level5/March01/Carroll3/Carroll3.html
It is worth noting that the other pages don't have this problem.
FYI: the index/content page is here:
http://ned.ipac.caltech.edu/level5/March01/Carroll3/Carroll_contents.html
Hello,
in latest Firefox (archlinux, clean profile, 59.0.1, the only extension is "Save as eBook"), one website is saved as HTML markup. This is
https://www.polskieradio.pl/39/156/Artykul/1068055,Stefan-Kisielewski-muzyk-polityk-felietonista
It doesn't matter if I save the full page or a selection of it.
Other websites I tested work fine.
Many, many thanks for this wonderful extension!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.