Skip to content

Commit

Permalink
cleanup: RoyalRoad chapter (LNReader#1133)
Browse files Browse the repository at this point in the history
  • Loading branch information
K1ngfish3r authored Aug 12, 2024
1 parent 48f2c2c commit 94b2e60
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/plugins/english/royalroad.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { NovelStatus } from '@libs/novelStatus';
class RoyalRoad implements Plugin.PluginBase {
id = 'royalroad';
name = 'Royal Road';
version = '2.1.0';
version = '2.1.1';
icon = 'src/en/royalroad/icon.png';
site = 'https://www.royalroad.com/';

Expand Down Expand Up @@ -234,6 +234,7 @@ class RoyalRoad implements Plugin.PluginBase {
const html = await result.text();
const parts: string[] = [];
const regexPatterns: RegExp[] = [
/<style>\n\s+.(.+?){[^]+speak: never;/,
/(<div class="portlet solid author-note-portlet"[^]+)<div class="margin-bottom-20/,
/(<div class="chapter-inner chapter-content"[^]+)<div class="portlet light t-center-3/,
/(<\/div>\s+<div class="portlet solid author-note-portlet"[^]+)<div class="row margin-bottom-10/,
Expand All @@ -246,8 +247,11 @@ class RoyalRoad implements Plugin.PluginBase {
});
};
extractContent(regexPatterns);
const chapterText = parts.join('<hr>');
return chapterText;
const cleanup = new RegExp(`<p class=\"${parts[0]}.+?<\/p>`, 'g');
const chapterText = parts.slice(1).join('<hr>');
return chapterText
.replace(cleanup, '')
.replace(/<p class=\"[^><]+>/g, '<p>');
}

async searchNovels(
Expand Down

0 comments on commit 94b2e60

Please sign in to comment.