diff --git a/src/plugins/english/webnovel.ts b/src/plugins/english/webnovel.ts index 7ff60f8..dad209e 100644 --- a/src/plugins/english/webnovel.ts +++ b/src/plugins/english/webnovel.ts @@ -6,7 +6,7 @@ import { Plugin } from '@typings/plugin'; class Webnovel implements Plugin.PluginBase { id = 'webnovel'; name = 'Webnovel'; - version = '1.0.0'; + version = '1.0.1'; icon = 'src/en/webnovel/icon.png'; site = 'https://www.webnovel.com'; headers = { @@ -63,6 +63,13 @@ class Webnovel implements Plugin.PluginBase { filters, }: Plugin.PopularNovelsOptions, ): Promise { + if (filters?.fanfic_search.value) { + return this.searchNovelsInternal( + filters.fanfic_search.value, + pageNo, + 'fanfic', + ); + } let url = this.site + '/stories/'; const params = new URLSearchParams(); @@ -214,10 +221,18 @@ class Webnovel implements Plugin.PluginBase { async searchNovels( searchTerm: string, pageNo: number, + ): Promise { + return this.searchNovelsInternal(searchTerm, pageNo); + } + + async searchNovelsInternal( + searchTerm: string, + pageNo: number, + type?: string, ): Promise { searchTerm = searchTerm.replace(/\s+/g, '+'); - const url = `${this.site}/search?keywords=${searchTerm}&pageIndex=${pageNo}`; + const url = `${this.site}/search?keywords=${searchTerm}&pageIndex=${pageNo}${type ? `&type=${type}` : ''}`; const result = await fetchApi(url, { headers: this.headers, }); @@ -306,6 +321,11 @@ class Webnovel implements Plugin.PluginBase { ], type: FilterTypes.Picker, }, + fanfic_search: { + label: 'Search fanfics (Overrides other filters)', + value: '', + type: FilterTypes.TextInput, + }, } satisfies Filters; }