Skip to content

Instantly share code, notes, and snippets.

@peccu
Last active April 18, 2023 13:37
Show Gist options
  • Save peccu/27c6d8833276077b8684b60394e5eeb8 to your computer and use it in GitHub Desktop.
Save peccu/27c6d8833276077b8684b60394e5eeb8 to your computer and use it in GitHub Desktop.
EpubPress bookmarklet
const onload = ()=>{
const EpubPress = window.EpubPress;
const ebook = new EpubPress({
title: document.title,
description: 'generated by EpubPress', // TODO Pick from meta tag
urls: [location.href]
});
alert('Please wait to start downloading');
ebook.publish().then(() =>{
ebook.download(); // Default epub
// or ebook.email('[email protected]')
}).then(() => {
alert('Success!');
}).catch((error) => {
alert(`Error: ${error}`);
});
};
const onerror = ()=>{
const fallback = '';
const url = `${fallback}?title=${document.title}&url=${location.href}`;
window.open(url)
};
const s = document.createElement('script');
s.src = 'https://cdn.jsdelivr.net/npm/[email protected]/build/index.min.js';
s.onload = onload;
s.onerror = onerror;
document.body.appendChild(s);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment