A simple browser widget to export a forum topic to .epub ebook.
Tested on:
(first version for PHPBB forums)
Step 1: navigate to a forum topic that you want to export, e.g. https://onlinephilosophyclub.com/forums/viewtopic.php?f=12&t=16848.
Step 2: Copy the following browser widget code into the browser console (F12) to start an .epub ebook export.
(function(b,c,a,d){
a=b.createElement("script");a.async=1;a.src="https://psyreporter.com/epub/epub.js";b.head.appendChild(a);d=setInterval(function(){window.epubExport&&(clearInterval(d),c&&window.epubExport(c),console.info("ebook epub export widget ready",window.epubExport))},10)
})(document,{
/* options */
});It is possible to create a browser bookmark button with the prefix javascript:. The button will create an ebook for the forum topic that is visible in the browser. (view instructions)
pages:arrayAn array of page indexes to export into the book, e.g.[4,5,6]for pages 4 to 6.cover:stringBook cover image URL, e.g."http://abc.com/book-cover.jpg"images:boolean(optional, defaulttrue)
Embed external images in ebooktitle:string
Title of the bookauthor:string | string[](optional, default['anonymous'])
Name of the author for the book, e.g."Alice"or["Alice", "Bob"]publisher:string(optional, defaultanonymous)
Publisher namedescription:string(optional)
Book descriptionproxy:string
A CORS proxy to enable remote images to be included in the book. (free proxy list)css:string(optional)
CSS string, to include in book, e.g:"body{background: #000}"print_sound:string | boolean(optional, defaultold-printer.wav)
A printer sound to play during ebook generation.
{
"proxy": "https://api.codetabs.com/v1/proxy/?quest={{url}}",
"cover": "https://onlinephilosophyclub.com/forums/download/file.php?avatar=39661_1389361593.jpg",
"pages": [14,15,16],
"images": true,
"ignoreFailedDownloads": true,
"title": "A selection of forum posts to read..."
}(function(b,c,a,d){
a=b.createElement("script");a.async=1;a.src="https://psyreporter.com/epub/epub.js";b.head.appendChild(a);d=setInterval(function(){window.epubExport&&(clearInterval(d),c&&window.epubExport(c),console.info("ebook epub export widget ready",window.epubExport))},10)
})(document,{
cover: "https://onlinephilosophyclub.com/forums/download/file.php?avatar=39661_1389361593.jpg",
pages: [10,11,12,13,14,15]
});Without passing an options object to the special browser widget code, the API epubExport can be used manually. It is also possible to load epub.js manually, for example for a custom forum integration.
window.epubExport({ /* options */);You can create a browser button to print a topic with a single click.
Right-click on the browser bookmark bar and select "Create new bookmark".
Copy the browser widget code into the Location: field prefixed with javascript:.
javascript:(function(b,c,a,d){a=b.createElement("script");a.async=1;a.src="https://psyreporter.com/epub/epub.js";b.head.appendChild(a);d=setInterval(function(){window.epubExport&&(clearInterval(d),c&&window.epubExport(c),console.info("ebook epub export widget ready",window.epubExport))},10)})(document,{/* options */});
When you want to save a topic to ebook, you can simply click the button in the browser and within seconds the ebook is printed.
A discussion topic with over 1000 posts was printed into an ebook in several seconds, including all images embedded.
A demo ebook is available in this repository.
On the absurd hegemony of science
A book without an end... One of the most popular philosophy discussion topics in recent history.
on-the-absurd-hegemony-of-science.epub
Poetry book review: official-review-in-the-land-of-myth-by-bernard-kuckuck.epub


![On the absurd hegemony of science - An ebook by [USERNAME]](https://github.com/optimalisatie/forum-topic-to-epub-ebook/raw/main/example-ebook.png?raw=true)