Hooks

List of hooks

https://seanime.rahim.app/docs/hooks

Usage

Hooks should be used carefully as they can introduce undefined behavior and even slow down the app.

Some hooks, like onGetAnime , are triggered very often, so it's a good habit to start by logging the event in order to figure out its frequency.

You should also avoid expensive calculations or fetch calls in hook handlers unless you can guarantee that the hook is not triggered often.

Any error/exception that happens in a hook handler will result in a server and client error. Test your code carefully.

Example
function init() {
   // This hook is triggered before Seanime formats the library data of an anime
   // The event contains the variables that Seanime will use, and you can modify them
   $app.onAnimeEntryLibraryDataRequested((e) => {
      // Setting this to an empty array will cause Seanime to think that the anime
      // has not been downloaded.
      e.entryLocalFiles = []
      
      e.next() // Continue hook chain
   })
}

Best Practices

Editing events

Let's say we want your plugin to change anime banner images based on what custom banner image has been set for that anime. However you want to do it without manipulating the DOM and before the page is even loaded.

We can use onGetAnimeCollection and onGetRawAnimeCollection since these are triggered when Seanime fetches the user's anime collection from AniList. Note that this will not change banner images for the same anime if it's fetched using another query (e.g. discover, search).

Listening to events

Let's say we want to make a plugin that stores the history of scanning durations.

Last updated