hoarder-app / hoarder

A self-hostable bookmark-everything app (links, notes and images) with AI-based automatic tagging and full text search
https://hoarder.app
GNU Affero General Public License v3.0
5.85k stars 190 forks source link

Support custom scripts/hooks #638

Open edongashi opened 4 days ago

edongashi commented 4 days ago

Describe the feature you'd like

Support hooking custom user code into the bookmark process. A /scripts directory could be mounted where named callbacks would be exported. For example, my-script.js would expose:

// --- Pseudocode for illustration purposes ---
module.exports = {
  async onBookmark(input, bookmark) {
    if (input.url && input.url.host.contains('youtube.com')) {
      bookmark.tags.add('videos');
    }
    if (input.url && input.url.host.contains('reddit.com')) {
      if (input.url.path.startswith('/r/funny') {
        bookmark.tags.add('entertainment')
      } else if (input.url.path.startswith('/r/programming') {
        bookmark.tags.add('technology')
        bookmark.tags.add('learning')
      }
    }
    return bookmark
  }
}

Similarly, we could have a onAITags to clean up the AI generated tags, onAiPrompt to fine tune a prompt, onContentCaptured, onSummary, and so on.

Describe the benefits this would bring to existing Hoarder users

There are some key sites where I commonly save links and I would like to apply some pre/postprocessing. Automatic tagging would be beneficial in a site such as reddit where it depends on which subreddit the bookmark was captured. This would also make it possible for third party integrations such as caling a webhook when something of interest has happened.

Another use case that comes to mind is parsing domain-specific languages for text notes.

Can the goal of this request already be achieved via other means?

No, the closest thing is customizing the AI prompts.

Have you searched for an existing open/closed issue?

Additional context

No response

joestump commented 7 hours ago

Just wanted to chime in here that I'd like this as well. My use case is very similar to @edongashi's – except I want to have Hoarder ingest the Reddit post's target URL rather than the Reddit post itself. FreshRSS has a plugin framework that lets you mutate data on ingestion or munge on display. Both would be useful.