Created
December 23, 2025 21:32
-
-
Save ejkarne/c75ab3fa1eca4685f966baec7c6cec39 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| local userpatch = require("userpatch") | |
| local function patchCoverBrowser(plugin) | |
| local BookInfoManager = require("bookinfomanager") | |
| local DocSettings = require("docsettings") | |
| local doc_pages_cache = {} | |
| local orig_getBookInfo = BookInfoManager.getBookInfo | |
| function BookInfoManager:getBookInfo(filepath, do_cover_image, ...) | |
| local bookinfo = orig_getBookInfo(self, filepath, do_cover_image, ...) | |
| if not bookinfo then | |
| return bookinfo | |
| end | |
| if bookinfo.pages == nil then | |
| local cached = doc_pages_cache[filepath] | |
| if cached ~= nil then | |
| if cached > 0 then | |
| bookinfo.pages = cached | |
| end | |
| return bookinfo | |
| end | |
| local pages = 0 | |
| local sidecar = DocSettings:findSidecarFile(filepath) | |
| if sidecar then | |
| local ok, docsettings = pcall(DocSettings.openSettingsFile, sidecar) | |
| if ok and docsettings then | |
| local n = tonumber(docsettings:readSetting("doc_pages")) | |
| if n and n > 0 then | |
| pages = n | |
| end | |
| end | |
| end | |
| doc_pages_cache[filepath] = pages | |
| if pages > 0 then | |
| bookinfo.pages = pages | |
| end | |
| end | |
| return bookinfo | |
| end | |
| end | |
| userpatch.registerPatchPluginFunc("coverbrowser", patchCoverBrowser) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment