Skip to content
Merged
Show file tree
Hide file tree
Changes from 17 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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,4 @@
"lint-staged": {
"**/*.{js,ts,jsx,tsx}": "prettier --write"
}
}
}
4 changes: 3 additions & 1 deletion scripts/multisrc/lightnovelwp/template.ts
Original file line number Diff line number Diff line change
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
5 changes: 1 addition & 4 deletions scripts/multisrc/madara/generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@ const generator = function generator(source) {
});

const pluginScript = `
${madaraTemplate.replace(
'// CustomJS HERE',
source.options?.customJs || '',
)}
${madaraTemplate.replace('// CustomJS HERE', source.options?.customJs || '')}
const plugin = new MadaraPlugin(${JSON.stringify(source)});
export default plugin;
`.trim();
Expand Down
49 changes: 32 additions & 17 deletions scripts/multisrc/madara/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 9 additions & 1 deletion src/plugins/english/novelupdates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Plugin } from '@typings/plugin';
class NovelUpdates implements Plugin.PluginBase {
id = 'novelupdates';
name = 'Novel Updates';
version = '0.7.15';
version = '0.8.0';
icon = 'src/en/novelupdates/icon.png';
customCSS = 'src/en/novelupdates/customCSS.css';
site = 'https://www.novelupdates.com/';
Expand Down Expand Up @@ -144,6 +144,14 @@ class NovelUpdates implements Plugin.PluginBase {

novel.summary = summary + `\n\nType: ${type}`;

const rating = loadedCheerio('.seriesother .uvotes')
.text()
.match(/(\d+\.\d+) \/ \d+\.\d+/)?.[1];

if (rating) {
novel.rating = parseFloat(rating);
}

const chapter: Plugin.ChapterItem[] = [];

const novelId = loadedCheerio('input#mypostid').attr('value')!;
Expand Down
2 changes: 2 additions & 0 deletions src/types/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ export namespace Plugin {
author?: string;
artist?: string;
status?: string;
/** Rating out of 5 as float */
rating?: number;
chapters?: ChapterItem[];
} & NovelItem;

Expand Down