Last active
September 24, 2025 16:22
-
-
Save mallomar/51c4fb0228ae03d4cd99aef4e8e43288 to your computer and use it in GitHub Desktop.
Pulls Up the Hardcover Quote Menu Immediately After Making a Highlight (Requires Hardcover.App Plugin: https://github.com/Billiam/hardcoverapp.koplugin)
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
| -- Hardcover Auto-Quote Final Patch | |
| -- Uses the official HardcoverNote event from plugin v0.1.3 | |
| local logger = require("logger") | |
| local Event = require("ui/event") | |
| local UIManager = require("ui/uimanager") | |
| logger.info("=== HARDCOVER AUTO-QUOTE FINAL PATCH LOADING ===") | |
| -- Hook into ReaderHighlight | |
| local ReaderHighlight = require("apps/reader/modules/readerhighlight") | |
| -- Store original onClose method | |
| local original_onClose = ReaderHighlight.onClose | |
| -- Hook into onClose (called when highlight dialog closes) | |
| if ReaderHighlight.onClose then | |
| ReaderHighlight.onClose = function(self, ...) | |
| logger.info("=== HIGHLIGHT DIALOG CLOSE TRIGGERED ===") | |
| -- Check if a highlight was just created | |
| local selected_text = self.selected_text | |
| if selected_text and selected_text.text then | |
| logger.info("Text from onClose:", selected_text.text) | |
| -- Get current page | |
| local current_page = self.ui:getCurrentPage() | |
| -- Create note parameters for the event | |
| local note_params = { | |
| text = selected_text.text, | |
| page_number = current_page, | |
| note_type = "quote" | |
| } | |
| -- Broadcast the HardcoverNote event | |
| UIManager:broadcastEvent(Event:new("HardcoverNote", note_params)) | |
| logger.info("HardcoverNote event broadcasted successfully") | |
| end | |
| -- Call original onClose if it exists | |
| if original_onClose then | |
| return original_onClose(self, ...) | |
| end | |
| end | |
| logger.info("Hooked into onClose") | |
| else | |
| logger.info("onClose method not found") | |
| end | |
| logger.info("=== HARDCOVER AUTO-QUOTE FINAL PATCH LOADED ===") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment