Action
ctx.action
The ctx.action
API allows your plugin to add UI elements to different parts of the Seanime interface. These elements can be buttons, dropdown items, or context menu items that trigger custom actions when clicked.
Creating Actions
newAnimePageButton(props)
Creates a button that appears on anime detail pages.
Parameters:
props
: Object containing:label
: String - Button textintent
: String (Optional) - Button style ("primary", "success", "warning", etc.)style
: Object (Optional) - Custom CSS styles
Returns: ActionObject
Example:
newAnimePageDropdownItem(props)
Creates a dropdown menu item that appears in the anime page's action menu.
Parameters:
props
: Object containing:label
: String - Menu item textstyle
: Object (Optional) - Custom CSS styles
Returns: ActionObject
Example:
newAnimeLibraryDropdownItem(props)
Creates a dropdown menu item that appears in the anime library's global action menu.
Parameters:
props
: Object containing:label
: String - Menu item textstyle
: Object (Optional) - Custom CSS styles
Returns: ActionObject
Example:
newMediaCardContextMenuItem(props)
Creates a context menu item that appears when right-clicking on media cards.
Parameters:
props
: Object containing:label
: String - Menu item textfor
: String (Optional) - Which media types to show for ("anime", "manga", or "both")style
: Object (Optional) - Custom CSS styles
Returns: ActionObject
Example:
newMangaPageButton(props)
Creates a button that appears on manga detail pages.
Parameters:
props
: Object containing:label
: String - Button textintent
: String (Optional) - Button style ("primary", "success", "warning", etc.)style
: Object (Optional) - Custom CSS styles
Returns: ActionObject
Example:
Action Object Methods
All action objects share these common methods:
mount()
Makes the action visible in the UI.
Example:
unmount()
Removes the action from the UI.
Example:
setLabel(label)
Updates the action's label text.
Parameters:
label
: String - New label text
Example:
setStyle(style)
Updates the action's custom CSS styles.
Parameters:
style
: Object - CSS style properties
Example:
onClick(callback)
Sets a function to be called when the action is clicked.
Parameters:
callback
: Function(event) - Function to call when clicked
Example:
Additional Properties
AnimePageButton and MangaPageButton
These button types have an additional method:
setIntent(intent)
Sets the button's visual style.
Parameters:
intent
: String - Intent style ("primary", "success", "warning", "error", etc.)
Example:
MediaCardContextMenuItem
This action type has an additional method:
setFor(type)
Sets which media types the context menu item appears for.
Parameters:
type
: String - "anime", "manga", or "both"
Example:
Best Practices
Limit Number of Actions
Each plugin is limited to a maximum of 3 actions per type. Choose the most important actions to display.
Dynamic UI Updates
Update action properties based on application state:
Conditional Mounting
Only mount actions when they're relevant:
Last updated