Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions scripts/multisrc/ifreedom/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class IfreedomPlugin implements Plugin.PluginBase {
this.name = metadata.sourceName;
this.icon = `multisrc/ifreedom/${metadata.id.toLowerCase()}/icon.png`;
this.site = metadata.sourceSite;
this.version = '1.0.1';
this.version = '1.0.2';
this.filters = metadata.filters;
}

Expand Down Expand Up @@ -166,7 +166,11 @@ class IfreedomPlugin implements Plugin.PluginBase {
page: number | undefined = 1,
): Promise<Plugin.NovelItem[]> {
const url =
this.site + '/vse-knigi/?searchname=' + searchTerm + '&bpage=' + page;
this.site +
'/vse-knigi/?searchname=' +
encodeURIComponent(searchTerm) +
'&bpage=' +
page;
const result = await fetchApi(url).then(res => res.text());
const loadedCheerio = parseHTML(result);

Expand Down
9 changes: 6 additions & 3 deletions scripts/multisrc/lightnovelwp/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class LightNovelWPPlugin implements Plugin.PluginBase {
this.icon = `multisrc/lightnovelwp/${metadata.id.toLowerCase()}/icon.png`;
this.site = metadata.sourceSite;
const versionIncrements = metadata.options?.versionIncrements || 0;
this.version = `1.1.${6 + versionIncrements}`;
this.version = `1.1.${7 + versionIncrements}`;
this.options = metadata.options ?? ({} as LightNovelWPOptions);
this.filters = metadata.filters satisfies Filters;

Expand Down Expand Up @@ -103,7 +103,9 @@ class LightNovelWPPlugin implements Plugin.PluginBase {

if (novelName && novelUrl) {
const novelCover =
article.match(/<img [^>]*?src="([^\"]*)"[^>]*?(?: data-src="([^\"]*)")?[^>]*>/) || [];
article.match(
/<img [^>]*?src="([^\"]*)"[^>]*?(?: data-src="([^\"]*)")?[^>]*>/,
) || [];

let novelPath;
if (novelUrl.includes(this.site)) {
Expand Down Expand Up @@ -444,7 +446,8 @@ class LightNovelWPPlugin implements Plugin.PluginBase {
searchTerm: string,
page: number,
): Promise<Plugin.NovelItem[]> {
const url = this.site + 'page/' + page + '/?s=' + searchTerm;
const url =
this.site + 'page/' + page + '/?s=' + encodeURIComponent(searchTerm);
const html = await this.safeFecth(url, true);
return this.parseNovels(html);
}
Expand Down
53 changes: 34 additions & 19 deletions scripts/multisrc/madara/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class MadaraPlugin implements Plugin.PluginBase {
this.icon = `multisrc/madara/${metadata.id.toLowerCase()}/icon.png`;
this.site = metadata.sourceSite;
const versionIncrements = metadata.options?.versionIncrements || 0;
this.version = `1.0.${6 + versionIncrements}`;
this.version = `1.0.${7 + versionIncrements}`;
this.options = metadata.options;
this.filters = metadata.filters;

Expand All @@ -62,26 +62,41 @@ class MadaraPlugin implements Plugin.PluginBase {

translateDragontea(text: Cheerio<AnyNode>): Cheerio<AnyNode> {
if (this.id !== 'dragontea') return text;

const $ = parseHTML(text.html()?.replace('\n', '').replace(/<br\s*\/?>/g, '\n') || '');

const $ = parseHTML(
text
.html()
?.replace('\n', '')
.replace(/<br\s*\/?>/g, '\n') || '',
);
const reverseAlpha = 'zyxwvutsrqponmlkjihgfedcbaZYXWVUTSRQPONMLKJIHGFEDCBA';
const forwardAlpha = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';

text.html($.html());
text.find('*').addBack().contents().filter((_, el) => el.nodeType === 3).each((_, el) => {
const $el = $(el);
const translated = $el.text().normalize('NFD').split('')
.map(char => {
const base = char.normalize('NFC');
const idx = forwardAlpha.indexOf(base);
return idx >= 0 ? reverseAlpha[idx] + char.slice(base.length) : char;
})
.join('');
$el.replaceWith(translated.replace('\n', '<br>'));
});

text
.find('*')
.addBack()
.contents()
.filter((_, el) => el.nodeType === 3)
.each((_, el) => {
const $el = $(el);
const translated = $el
.text()
.normalize('NFD')
.split('')
.map(char => {
const base = char.normalize('NFC');
const idx = forwardAlpha.indexOf(base);
return idx >= 0
? reverseAlpha[idx] + char.slice(base.length)
: char;
})
.join('');
$el.replaceWith(translated.replace('\n', '<br>'));
});

return text;
}
}

getHostname(url: string): string {
url = url.split('/')[2];
Expand Down Expand Up @@ -261,7 +276,7 @@ class MadaraPlugin implements Plugin.PluginBase {
if (this.options?.useNewChapterEndpoint) {
html = await fetchApi(this.site + novelPath + 'ajax/chapters/', {
method: 'POST',
referrer: this.site + novelPath
referrer: this.site + novelPath,
}).then(res => res.text());
} else {
const novelId =
Expand Down Expand Up @@ -347,7 +362,7 @@ class MadaraPlugin implements Plugin.PluginBase {
'/page/' +
pageNo +
'/?s=' +
searchTerm +
encodeURIComponent(searchTerm) +
'&post_type=wp-manga';
const loadedCheerio = await this.getCheerio(url, true);
return this.parseNovels(loadedCheerio);
Expand Down
6 changes: 4 additions & 2 deletions scripts/multisrc/mtlnovel/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class MTLNovelPlugin implements Plugin.PluginBase {
this.icon = 'multisrc/mtlnovel/mtlnovel/icon.png';
this.site = metadata.sourceSite;
this.mainUrl = 'https://www.mtlnovels.com/';
this.version = '1.1.2';
this.version = '1.1.3';
this.options = metadata.options ?? ({} as MTLNovelOptions);
this.filters = metadata.filters satisfies Filters;
}
Expand Down Expand Up @@ -203,7 +203,9 @@ class MTLNovelPlugin implements Plugin.PluginBase {
): Promise<Plugin.NovelItem[]> {
if (pageNo !== 1) return [];
const searchUrl =
this.site + 'wp-admin/admin-ajax.php?action=autosuggest&q=' + searchTerm;
this.site +
'wp-admin/admin-ajax.php?action=autosuggest&q=' +
encodeURIComponent(searchTerm);

const res = await this.safeFecth(searchUrl);
const result = await res.json();
Expand Down
4 changes: 2 additions & 2 deletions scripts/multisrc/readnovelfull/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class ReadNovelFullPlugin implements Plugin.PluginBase {
this.icon = `multisrc/readnovelfull/${metadata.id.toLowerCase()}/icon.png`;
this.site = metadata.sourceSite;
const versionIncrements = metadata.options?.versionIncrements || 0;
this.version = `1.0.${0 + versionIncrements}`;
this.version = `1.0.${1 + versionIncrements}`;
this.options = metadata.options;
}

Expand Down Expand Up @@ -229,7 +229,7 @@ class ReadNovelFullPlugin implements Plugin.PluginBase {
this.site +
'/' +
this.options?.searchPage
.replace('%%SEARCH%%', searchTerm)
.replace('%%SEARCH%%', encodeURIComponent(searchTerm))
.replace('%%PAGE%%', page.toString());
const $ = await this.getCheerio(url, true);

Expand Down
6 changes: 4 additions & 2 deletions scripts/multisrc/rulate/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class RulatePlugin implements Plugin.PluginBase {
this.name = metadata.sourceName;
this.icon = `multisrc/rulate/${metadata.id.toLowerCase()}/icon.png`;
this.site = metadata.sourceSite;
this.version = '1.0.' + (1 + metadata.versionIncrements);
this.version = '1.0.' + (2 + metadata.versionIncrements);
this.filters = metadata.filters;
}

Expand Down Expand Up @@ -217,7 +217,9 @@ class RulatePlugin implements Plugin.PluginBase {
async searchNovels(searchTerm: string): Promise<Plugin.NovelItem[]> {
const novels: Plugin.NovelItem[] = [];
const result: response[] = await fetchApi(
this.site + '/search/autocomplete?query=' + searchTerm,
this.site +
'/search/autocomplete?query=' +
encodeURIComponent(searchTerm),
).then(res => res.json());

result.forEach(novel => {
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/english/allnovelfull.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class AllNovelFullPlugin implements Plugin.PluginBase {
name = 'AllNovelFull';
icon = 'src/en/allnovelfull/icon.png';
site = 'https://allnovelfull.net';
version = '1.0.1';
version = '1.0.2';

parseNovels(loadedCheerio: CheerioAPI) {
const novels: Plugin.NovelItem[] = [];
Expand Down Expand Up @@ -140,7 +140,7 @@ class AllNovelFullPlugin implements Plugin.PluginBase {
searchTerm: string,
page: number,
): Promise<Plugin.NovelItem[]> {
const url = `${this.site}/search?keyword=${searchTerm}&page=${page}`;
const url = `${this.site}/search?keyword=${encodeURIComponent(searchTerm)}&page=${page}`;
const result = await fetchApi(url);
const body = await result.text();

Expand Down
4 changes: 2 additions & 2 deletions src/plugins/english/ao3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { defaultCover } from '@libs/defaultCover';
class ArchiveOfOurOwn implements Plugin.PluginBase {
id = 'archiveofourown';
name = 'Archive Of Our Own';
version = '1.0.2';
version = '1.0.3';
icon = 'src/en/ao3/icon.png';
site = 'https://archiveofourown.org/';

Expand Down Expand Up @@ -282,7 +282,7 @@ class ArchiveOfOurOwn implements Plugin.PluginBase {
searchTerm: string,
page: number,
): Promise<Plugin.NovelItem[]> {
const searchUrl = `${this.site}works/search?page=${page}&work_search%5Blanguage_id%5D=en&work_search%5Bquery%5D=${searchTerm}`;
const searchUrl = `${this.site}works/search?page=${page}&work_search%5Blanguage_id%5D=en&work_search%5Bquery%5D=${encodeURIComponent(searchTerm)}`;

const result = await fetchApi(searchUrl);
const body = await result.text();
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/english/bestlightnovel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class BLN implements Plugin.PluginBase {
name = 'BestLightNovel';
icon = 'src/en/bestlightnovel/icon.png';
site = 'https://bestlightnovel.com/';
version = '1.0.0';
version = '1.0.1';

parseNovels(loadedCheerio: CheerioAPI) {
const novels: Plugin.NovelItem[] = [];
Expand Down Expand Up @@ -160,7 +160,7 @@ class BLN implements Plugin.PluginBase {
searchTerm: string,
page: number,
): Promise<Plugin.NovelItem[]> {
const url = `${this.site}search_novels/${searchTerm}?page=${page}`;
const url = `${this.site}search_novels/${encodeURIComponent(searchTerm)}?page=${page}`;

const result = await fetchApi(url);
const body = await result.text();
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/english/comrademao.broken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class ComradeMaoPlugin implements Plugin.PluginBase {
id = 'comrademao';
name = 'Comrade Mao';
site = 'https://comrademao.com/';
version = '1.0.0';
version = '1.0.1';
icon = 'src/en/comrademao/icon.png';

parseNovels(loadedCheerio: CheerioAPI) {
Expand Down Expand Up @@ -149,7 +149,7 @@ class ComradeMaoPlugin implements Plugin.PluginBase {
searchTerm: string,
pageNo: number,
): Promise<Plugin.NovelItem[]> {
const url = `${this.site}page/${pageNo}/?s=${searchTerm}&post_type=novel`;
const url = `${this.site}page/${pageNo}/?s=${encodeURIComponent(searchTerm)}&post_type=novel`;

const body = await fetchApi(url).then(result => result.text());

Expand Down
4 changes: 3 additions & 1 deletion src/plugins/english/divinedaolibrary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ import { Filters, FilterTypes, FilterValueWithType } from '@libs/filterInputs';
import { Plugin } from '@typings/plugin';
import { load as parseHTML } from 'cheerio';

//TODO: this looks similar to fictioneer source? maybe use multisrc someday

class DDLPlugin implements Plugin.PluginBase {
id = 'DDL.com';
name = 'Divine Dao Library';
site = 'https://www.divinedaolibrary.com/';
version = '1.1.0';
version = '1.1.1';
icon = 'src/en/divinedaolibrary/icon.png';

filters = {
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/english/earlynovel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Plugin } from '@typings/plugin';
class EarlyNovelPlugin implements Plugin.PagePlugin {
id = 'earlynovel';
name = 'Early Novel';
version = '1.0.0';
version = '1.0.1';
icon = 'src/en/earlynovel/icon.png';
site = 'https://earlynovel.net/';

Expand Down Expand Up @@ -128,7 +128,7 @@ class EarlyNovelPlugin implements Plugin.PagePlugin {
}

async searchNovels(searchTerm: string): Promise<Plugin.NovelItem[]> {
const url = `${this.site}search?keyword=${searchTerm}`;
const url = `${this.site}search?keyword=${encodeURIComponent(searchTerm)}`;
const result = await fetchApi(url);
const body = await result.text();

Expand Down
4 changes: 2 additions & 2 deletions src/plugins/english/genesis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Genesis implements Plugin.PluginBase {
icon = 'src/en/genesis/icon.png';
customCSS = 'src/en/genesis/customCSS.css';
site = 'https://genesistudio.com';
version = '1.1.0';
version = '1.1.1';

imageRequestInit?: Plugin.ImageRequestInit | undefined = {
headers: {
Expand Down Expand Up @@ -465,7 +465,7 @@ class Genesis implements Plugin.PluginBase {
pageNo: number,
): Promise<Plugin.SourceNovel[]> {
if (pageNo !== 1) return [];
const url = `${this.site}/api/novels/search?serialization=All&sort=Popular&title=${searchTerm}`;
const url = `${this.site}/api/novels/search?serialization=All&sort=Popular&title=${encodeURIComponent(searchTerm)}`;
const json = await fetchApi(url).then(r => r.json());
return this.parseNovels(json);
}
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/english/mtlreader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Plugin } from '@typings/plugin';
class MTLReader implements Plugin.PluginBase {
id = 'mtlreader';
name = 'MTL Reader';
version = '1.0.0';
version = '1.0.1';
icon = 'src/en/mtlreader/icon.png';
site = 'https://mtlreader.com/';

Expand Down Expand Up @@ -92,7 +92,7 @@ class MTLReader implements Plugin.PluginBase {
const tokenCheerio = parseHTML(body);
const token = tokenCheerio('input[name="_token"]').attr('value');

const searchUrl = `${this.site}search?_token=${token}&input=${searchTerm}`;
const searchUrl = `${this.site}search?_token=${token}&input=${encodeURIComponent(searchTerm)}`;
const seacrhBody = await fetchApi(searchUrl).then(r => r.text());
const loadedCheerio = parseHTML(seacrhBody);
return this.parseNovels(loadedCheerio);
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/english/novelbin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class NovelBin implements Plugin.PluginBase {
icon = 'src/en/novelbin/icon.png';
site = 'https://novelbin.com/';
subsite = 'https://novelbin.lanovels.net/';
version = '1.2.0';
version = '1.2.1';
imageRequestInit?: Plugin.ImageRequestInit | undefined = {
headers: {
'referrer': this.site,
Expand Down Expand Up @@ -144,7 +144,7 @@ class NovelBin implements Plugin.PluginBase {
}

async searchNovels(searchTerm: string): Promise<Plugin.NovelItem[]> {
const url = `${this.site}search/?keyword=${searchTerm}`;
const url = `${this.site}search/?keyword=${encodeURIComponent(searchTerm)}`;
const body = await fetchApi(url).then(r => r.text());

const loadedCheerio = parseHTML(body);
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/english/novelbuddy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class NovelBuddy implements Plugin.PluginBase {
id = 'novelbuddy';
name = 'NovelBuddy.io';
site = 'https://novelbuddy.io/';
version = '1.0.2';
version = '1.0.3';
icon = 'src/en/novelbuddy/icon.png';

parseNovels(loadedCheerio: CheerioAPI) {
Expand Down Expand Up @@ -177,7 +177,7 @@ class NovelBuddy implements Plugin.PluginBase {
searchTerm: string,
page: number,
): Promise<Plugin.NovelItem[]> {
const url = `${this.site}search?q=${searchTerm}&page=${page}`;
const url = `${this.site}search?q=${encodeURIComponent(searchTerm)}&page=${page}`;

const result = await fetchApi(url);
const body = await result.text();
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/english/novelfire.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Plugin } from '@typings/plugin';
class NovelFire implements Plugin.PluginBase {
id = 'novelfire';
name = 'Novel Fire';
version = '1.0.1';
version = '1.0.2';
icon = 'src/en/novelfire/icon.png';
site = 'https://novelfire.net/';

Expand Down Expand Up @@ -230,7 +230,7 @@ class NovelFire implements Plugin.PluginBase {
searchTerm: string,
page: number,
): Promise<Plugin.NovelItem[]> {
const url = `${this.site}search?keyword=${searchTerm}&page=${page}`;
const url = `${this.site}search?keyword=${encodeURIComponent(searchTerm)}&page=${page}`;
const result = await fetchApi(url);
const body = await result.text();

Expand Down
Loading