Skip to content

Instantly share code, notes, and snippets.

View dmalinovsky's full-sized avatar

Denis Malinovsky dmalinovsky

  • USA
  • 16:35 (UTC -07:00)
View GitHub Profile
@dmalinovsky
dmalinovsky / 2-reload-book-on-hyphen-change.lua
Created April 14, 2025 19:38
Patch for KOReader to reload current book after making user hyphenation change
-- See https://github.com/koreader/koreader/issues/13462 for the details.
local ReaderUserHyph = require("apps/reader/modules/readeruserhyph")
ReaderUserHyph.loadUserDictionary = function(self, reload)
self:loadDictionary(self:isAvailable() and self:getDictionaryPath() or "", reload and true or false)
self.ui:handleEvent(Event:new("UpdatePos", reload))
end
@dmalinovsky
dmalinovsky / 2-open-url.lua
Last active March 21, 2025 17:26
Patch for KOReader to open the selected text as an URL in the browser
local Device = require("device")
local ReaderHighlight = require("apps/reader/modules/readerhighlight")
local util = require("util")
local init_orig = ReaderHighlight.init
ReaderHighlight.init = function(self)
init_orig(self)
self:addToHighlightDialog("08_open_url", function(this)
@dmalinovsky
dmalinovsky / 2-auto-save-font-size.lua
Last active February 5, 2025 20:33
Patch for KOReader to save font size as default after its change
local ReaderFont = require("apps/reader/modules/readerfont")
local onSetFontSize_orig = ReaderFont.onSetFontSize
ReaderFont.onSetFontSize = function(self, size)
-- Run original code
res = onSetFontSize_orig(self, size)
G_reader_settings:saveSetting("copt_font_size", size)
return res
end
@dmalinovsky
dmalinovsky / 2-logical-page-count.lua
Created April 2, 2024 23:02
Patch for KOReader to build logical page count
local ReaderPageMap = require("apps/reader/modules/readerpagemap")
local postInit_orig = ReaderPageMap._postInit
ReaderPageMap._postInit = function(self)
self.ui.document:buildSyntheticPageMapIfNoneDocumentProvided(1818)
-- Run original code
postInit_orig(self)
end