Skip to content
Open
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: 8 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,14 @@ export default tseslint.config(
},
},
},
{
files: ['**/*.mjs'],
languageOptions: {
globals: {
...globals.node,
},
},
},
{
files: ['**/fictioneer/custom/*/*.js'],
rules: {
Expand Down
3 changes: 2 additions & 1 deletion plugins/multisrc/madara/sources.json
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@
"options": {
"useNewChapterEndpoint": true,
"lang": "Arabic",
"customJs": "chapterText.find('span[style*=\"opacity: 0; position: fixed;\"],[role=\"presentation\"]').remove();"
"versionIncrements": 1,
"customJs": "chapterText.find('[data-nosnippet], style, script, input, .nhv-reader-store-promo').remove();"
}
},
{
Expand Down
52 changes: 47 additions & 5 deletions plugins/multisrc/madara/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,15 @@ export class MadaraPlugin implements Plugin.PluginBase {
loadedCheerio('.post-title h1').text().trim() ||
loadedCheerio('#manga-title h1').text().trim() ||
loadedCheerio('.manga-title').text().trim() ||
loadedCheerio('h1.nhv-novel-title').text().trim() ||
'',
};

novel.cover =
loadedCheerio('.summary_image > a > img').attr('data-lazy-src') ||
loadedCheerio('.summary_image > a > img').attr('data-src') ||
loadedCheerio('.summary_image > a > img').attr('src') ||
loadedCheerio('img.wp-post-image').attr('src') ||
defaultCover;

loadedCheerio('.post-content_item, .post-content').each(function () {
Expand Down Expand Up @@ -270,6 +272,30 @@ export class MadaraPlugin implements Plugin.PluginBase {
);
}

// Checks for the "novel" Madara child theme (nhv-*, e.g. Riwyat / cenele.com).
// Existence-guarded: only applies when this theme's elements are actually on
// the page, so classic Madara/NovelHub sites are untouched.
{
const nhvStatus = loadedCheerio('.nhv-novel-status');
if (nhvStatus.length > 0)
novel.status = nhvStatus.text().includes('مستمرة')
? NovelStatus.Ongoing
: NovelStatus.Completed;

const nhvGenres = loadedCheerio('.nhv-novel-genres');
if (nhvGenres.length > 0)
novel.genres = nhvGenres
.find('a')
.map((i, el) => loadedCheerio(el).text().trim())
.get()
.join(', ');

const nhvAuthors = loadedCheerio(
'.nhv-novel-meta a[href*="cont-author"]',
);
if (nhvAuthors.length > 0) novel.author = nhvAuthors.text().trim();
}

if (!novel.author)
novel.author = loadedCheerio('.manga-authors').text().trim();

Expand Down Expand Up @@ -386,10 +412,22 @@ export class MadaraPlugin implements Plugin.PluginBase {
async parseChapter(chapterPath: string): Promise<string> {
const loadedCheerio = await this.getCheerio(this.site + chapterPath, false);
const chapterText =
loadedCheerio('.text-left') ||
loadedCheerio('.text-right') ||
loadedCheerio('.entry-content') ||
loadedCheerio('.c-blog-post > div > div:nth-child(2)');
(loadedCheerio('.text-left').length > 0 && loadedCheerio('.text-left')) ||
(loadedCheerio('.text-right').length > 0 &&
loadedCheerio('.text-right')) ||
(loadedCheerio('.reading-content').length > 0 &&
loadedCheerio('.reading-content')) ||
(loadedCheerio('.entry-content').length > 0 &&
loadedCheerio('.entry-content')) ||
(loadedCheerio('.c-blog-post > div > div:nth-child(2)').length > 0 &&
loadedCheerio('.c-blog-post > div > div:nth-child(2)')) ||
null;

if (!chapterText || chapterText.length === 0) {
throw new Error(
`Chapter content container not found for ${chapterPath}: site layout may have changed; retry`,
);
}

if (this.options?.customJs) {
try {
Expand All @@ -400,7 +438,11 @@ export class MadaraPlugin implements Plugin.PluginBase {
}
}

return this.translateDragontea(chapterText).html() || '';
const html = this.translateDragontea(chapterText).html();
if (!html || html.trim().length === 0) {
throw new Error(`Chapter content empty after parsing for ${chapterPath}`);
}
return html;
}

async searchNovels(
Expand Down
Loading
Loading