Skip to content

Instantly share code, notes, and snippets.

@dmalinovsky
Last active March 21, 2025 17:26
Show Gist options
  • Save dmalinovsky/f9cb7640294108d66b180401e788cc79 to your computer and use it in GitHub Desktop.
Save dmalinovsky/f9cb7640294108d66b180401e788cc79 to your computer and use it in GitHub Desktop.
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)
return {
text = "Open as URL",
callback = function()
local text = util.cleanupSelectedText(this.selected_text.text)
this:onClose()
Device:openLink(text)
end,
}
end)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment