Skip to content
Miru

Getting Started

To develop extensions, you need to have a good understanding of JavaScript and regular expressions. If you are not familiar with regular expressions, you can start by learning ”Regular Expressions and String Methods” and ”Regular Expressions in 30 Minutes“.

This documentation assumes that you have already set up the development environment as described in the Environment Setup section.

Quick Start

Create Extension File

Please create a JavaScript file with the same name as your package name in the extension loading directory on Windows.

Write Metadata

The metadata contains basic information about the extension, such as the package name, version, author, description, etc. Write the metadata in the extension file, and it must be enclosed between // ==MiruExtension== comments.

Metadata example:


// ==MiruExtension==
// @name  Extension Name
// @version v0.0.1
// @author Xxxx
// @lang zh-cn
// @icon https://xxx.xxx.xxx/xxx.png
// @package xxx.xxx.xxx
// @type bangumi
// @webSite https://xxx.xxx.xxx/
// ==/MiruExtension==

Extends Extension Class

In the extension file, export a class that extends the Extension class. For example:

export default class extends Extension {}

Override Methods in the Extension

In the extension class, override the methods from the Extension class. For example:

export default class extends Extension {
  async latest() {
    // Latest updates
  }
  async search() {
    // Search
  }
  async detail() {
    // Details
  }
  async watch() {
    // Watch
  }
}

The returned data should follow the data format. You can use the this.request method to make requests, for example:

const res = await this.request({
  url: "/xxx",
  method: "GET",
});

this.request is a proxy request. If you don’t use this.request, you may encounter cross-origin errors (Web only).

Submit to the Miru Extension Repository

Please submit your extension to the Miru Extension Repository using PR. The submitted PR needs to contain your extension file and does not need the index.json file.

Example

You can visit the Miru Official Repository for examples.