From bc22699baba4fd8f3799a66fee35a51052ae81ea Mon Sep 17 00:00:00 2001 From: John Factotum <50942278+johnfactotum@users.noreply.github.com> Date: Fri, 4 Nov 2022 10:43:30 +0000 Subject: [PATCH] EPUB: add a method for getting Calibre bookmarks See https://github.com/johnfactotum/foliate/issues/849 --- epub.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/epub.js b/epub.js index 4247cb9..1c7fed5 100644 --- a/epub.js +++ b/epub.js @@ -736,4 +736,12 @@ export class EPUB { isExternal(uri) { return isExternal(uri) } + async getCalibreBookmarks() { + const txt = await this.loadText('META-INF/calibre_bookmarks.txt') + const magic = 'encoding=json+base64:' + if (txt?.startsWith(magic)) { + const json = atob(txt.slice(magic.length)) + return JSON.parse(json) + } + } }