Most of the Plugin/Novel type definitions accessed using the Plugin
namespace imported via
import { Plugin } from "@typings/plugin";
PluginBase is a base class for all plugins.
class ExamplePlugin implements Plugin.PluginBase {}
Field | Required | Description |
---|---|---|
id | yes | Plugin ID |
name | yes | Plugin Name |
icon | yes | Plugin Icon |
site | yes | Plugin site link |
version | yes | Plugin version |
imageRequestInit | no | Plugin Image Request Init |
filters | no | Filter definition object |
popularNovels(page, options) | yes | Novel list getter |
parseNovelAndChapters(url) | yes | Novel info and chapter list getter |
parseChapter(url) | yes | Chapter text getter |
searchNovels(searchTerm, page) | yes | Novel searching getter |
Unique ID of your plugin
class ExamplePlugin implements Plugin.PluginBase {
...
id = "templateID";
...
}
The name of your plugin that is shown in-app
class ExamplePlugin implements Plugin.PluginBase {
...
name = "template Plugin";
...
}
The path to your plugin's icon inside of icon
folder
class ExamplePlugin implements Plugin.PluginBase {
...
icon = "src/eng/templateplugin/icon.png";
...
}
Warning
Icons should be 96x96px
The url to the plugin's site
class ExamplePlugin implements Plugin.PluginBase {
...
site = "https://example.com";
...
}
Version of your plugin formatted according to semver2.0 spec i.e. <major>.<minor>.<patch>
Where
patch
increments on small fixes that fix the plugin (like site changed a selector, filter had a typo etc.)minor
increments on fixes that improve the plugin (like adding/removing filters, adding search options etc.)major
increments on fixes that fix the major issues with the plugin (like changing site link)
class ExamplePlugin implements Plugin.PluginBase {
...
version = "1.0.0";
...
}
The init for request to obtain images
Used if images failed to load due to site's protection
class ExamplePlugin implements Plugin.PluginBase {
...
imageRequestInit: Plugin.ImageRequestInit = {
headers: {
Referer: 'https://example.com',
},
};
...
}
A Filter definition object that holds filters used in popularNovels function
class ExamplePlugin implements Plugin.PluginBase {
...
filters = {
order: {
label:"Order",
options: [
{ label: "Popular", value: "" },
{ label: "Newest", value: "newest" }
],
type: FilterTypes.Picker,
value: ""
},
status: {
label: "Status",
options: [
{ label: "All", value: "" },
{ label: "Ongoing", value: "ongoing" },
{ label: "Hiatus", value: "hiatus" },
{ label: "Completed", value: "completed" },
],
type: FilterTypes.Picker,
value: "",
}
}
...
}
Function that is used to get the (filtered) list of novels from the front page of the site
async popularNovels(
page: number,
options: Plugin.PopularNovelsOptions<typeof this.filters>
): Promise<Plugin.NovelItem[]>
See Using cheerio for more information on how to parse HTML documents
page
current page to fetchoptions
PopularNovelsOptions
NovelItem[]
An array of filtered main-page NovelItems
class ExamplePlugin implements Plugin.PluginBase {
...
async popularNovels(
page: number,
options: Plugin.PopularNovelsOptions<typeof this.filters>
): Promise<Plugin.NovelItem[]> {
const novels: Plugin.NovelItem[] = [];
if(options.filters.example.value === "test"){
novels.push({
name: "Novel1",
url: "https://example.com/novel1",
cover:defaultCover
})
}
return novels;
}
}
This type is used for getting the options of the popularNovels function
-
showLatestNovels: boolean
flag set when opened withLatest
button -
filters: FilterValues<typeof filters>
object containing all selected filter values. More about Filters
Function that is used to get the information about particular novel and the list of it's chapters
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel>
See Using cheerio for more information on how to parse HTML documents
novelUrl
value from NovelItem::url
SourceNovel
Novel information and chapter list as SourceNovel object
[!CAUTION] > SourceNovel::url should be the same value as NovelItem::url provided as parameter!
class ExamplePlugin implements Plugin.PluginBase {
...
async parseNovelAndChapters(novelUrl: string): Promise<Plugin.SourceNovel> {
const novel: Plugin.SourceNovel = {
url: novelUrl,
name: "test",
artist: "none",
author: "none",
cover: defaultCover,
genres: "Isekai, Neverland",
status: NovelStatus.Completed,
summary: ""
};
let chapters: Plugin.ChapterItem[] = [];
const chapter: Plugin.ChapterItem = {
name: "",
url: "",
releaseTime: "",
chapterNumber: 0,
};
chapters.push(chapter);
novel.chapters = chapters;
return novel;
}
...
}
Function that is used to get the information about particular novel and the list of it's chapters
async parseChapter(chapterUrl: string): Promise<string>
See Using cheerio for more information on how to parse HTML documents
chapterUrl
value from ChapterItem::url
string
HTML content of the chapter
class ExamplePlugin implements Plugin.PluginBase {
...
async parseChapter(chapterUrl: string): Promise<string>{
return "<h1>No chapter here</h1>";
}
...
}
Function that is used to find Novels in the source
async searchNovels(searchTerm: string, pageNo: number): Promise<Plugin.NovelItem[]>
See Using cheerio for more information on how to parse HTML documents
searchTerm
the search termpage
search page number
NovelItem[]
An array of found NovelItems
class ExamplePlugin implements Plugin.PluginBase {
...
async searchNovels(
searchTerm: string,
pageNo: number
): Promise<Plugin.NovelItem[]> {
let novels: Plugin.NovelItem[] = [];
return novels;
}
...
}
It is an object representing information how to store/access the novel
Field | type | Required | Description |
---|---|---|---|
url |
string |
yes | The url to the site |
name |
string |
yes | The name of the novel shown in the library |
cover |
string |
no | URL to novel's cover |
You can use the default Cover not available
cover by importing
import { defaultCover } from "@libs/defaultCover";
Field | Type | Required | Desciption |
---|---|---|---|
url | string | yes | |
name | string | no | string |
cover | string |
no | |
genres | string |
no | |
summary | string |
no | |
author | string |
no | |
artist | string |
no | |
status | [NovelStatus] or string |
no |
chapters?: ChapterItem[];
Filters
and FilterTypes
are not in the Plugin
namespace and are from @libs/filterInputs
file:
import { FilterTypes, Filters } from "@libs/filterInputs";
There are 2 main objects when using filters:
- Filter definition object
- FilterValues object
This is the user-defined object that defines strictly what filters are available in the "filter" menu in app. Every property of this object is a different filter. The key of the object is the name that will be used to reference this filter's value in the FilterValues object
filters = {
order: {<FilterProperties>}
} satisfies Filters;
// accessible in popularNovels as
options.filters.order
Caution
Do not forget to add satisfies Filters
after the Filter definition object!
Name | Type | Required | Desciption |
---|---|---|---|
label | string |
yes | in-app label |
type | FilterTypes |
yes | type of the filter |
value | check types | yes | Default value for this filter and the starting filter state in-app |
options | check types | in some types | The options available in the given type |
filters = {
genre: {
type: FilterTypes.CheckboxGroup,
label: "Genres",
value: [],
options: [
{ label: "Isekai", value: "isekai" },
{ label: "Romance", value: "romans" },
],
},
} satisfies Filters;
Types of filters supported
FilterType | Description | value |
options |
---|---|---|---|
Picker |
A spinner for choosing one of the choices provided in options |
string the picked value |
Picker options |
TextInput |
A filter allowing a free text input | string written value |
N/A |
Switch |
A boolean switch | boolean state of the switch |
N/A |
CheckboxGroup |
A grouping of checkboxes | string[] array containing selected values |
CheckboxGroup options |
ExcludableCheckboxGroup |
A filter allowing to pick one of the choices provided in options |
ExcludableCheckboxGroupValues object | CheckboxGroup options |
options: [
{
label: "default", // in-app label
value: "", // in-code value
},
{
label: "Value ABC",
value: "abc",
},
];
options: [
{
label: "Value ABC", // in-app label
value: "abc", // in-code value
},
{
label: "Value DEF",
value: "def",
},
];
It is an object used inisde of popularNovels
that contains selected values for all filters defined in the Filter definition object.
The keys of the filter values correspond to Filter definition keys
// Filter definition object
filters = { abc: {} } satisfies Filters;
// then
options.filters; // FilterValues
options.filters.abc; // FilterValue for abc filter
Properties of FilterValue:
type: FilterType
type of the filtervalue
value dependent on FilterTypes
options.filters.abc.value; // value of the filter
options.filters.abc.type; // type of the filter
{
included: string[], // options with selected selected
excluded: string[] // options with excluded selected
}