Skip to content

Commit f65e460

Browse files
committed
lightnovelwp: fixed locked chapter numbers
1 parent 9d8c522 commit f65e460

15 files changed

Lines changed: 62 additions & 59 deletions

File tree

plugins/english/relibrary.ts

Lines changed: 37 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -215,12 +215,8 @@ class ReLibraryPlugin implements Plugin.PluginBase {
215215
novel.path = $(el).find('table > tbody > tr > td > a').attr('href');
216216
if (novel.name === undefined || novel.path === undefined) return;
217217
novel.cover = this.ensureCover(
218-
$(el)
219-
.find('table > tbody > tr > td > a > img')
220-
.attr('data-cfsrc') ||
221-
$(el)
222-
.find('table > tbody > tr > td > a > img')
223-
.attr('src')
218+
$(el).find('table > tbody > tr > td > a > img').attr('data-cfsrc') ||
219+
$(el).find('table > tbody > tr > td > a > img').attr('src'),
224220
);
225221
if (novel.path.startsWith(this.site)) {
226222
novel.path = novel.path.slice(this.site.length);
@@ -246,9 +242,9 @@ class ReLibraryPlugin implements Plugin.PluginBase {
246242
$(el)
247243
.find('.entry-content > table > tbody > tr > td > a >img')
248244
.attr('data-cfsrc') ||
249-
$(el)
250-
.find('.entry-content > table > tbody > tr > td > a >img')
251-
.attr('src')
245+
$(el)
246+
.find('.entry-content > table > tbody > tr > td > a >img')
247+
.attr('src'),
252248
);
253249
if (novel.path.startsWith(this.site)) {
254250
novel.path = novel.path.slice(this.site.length);
@@ -290,9 +286,7 @@ class ReLibraryPlugin implements Plugin.PluginBase {
290286
const $ = loadCheerio(body);
291287

292288
// If it doesn't find the name I should just throw an error (or early return) since the scraping is broken
293-
novel.name = $('header.entry-header > .entry-title')
294-
.text()
295-
.trim();
289+
novel.name = $('header.entry-header > .entry-title').text().trim();
296290

297291
if (novel.name === undefined || novel.name === '404 – Page not found')
298292
throw new Error(`Invalid novel for url ${novelPath}`);
@@ -301,51 +295,39 @@ class ReLibraryPlugin implements Plugin.PluginBase {
301295
novel.cover = this.ensureCover(
302296
// $('.entry-content > table > tbody > tr > td > a > img')
303297
$('.entry-content > table img').attr('data-cfsrc') ||
304-
$('.entry-content > table img').attr('src')
298+
$('.entry-content > table img').attr('src'),
305299
);
306300

307301
novel.status = NovelStatus.Unknown;
308-
$('.entry-content > table > tbody > tr > td > p').each(
309-
function (_i, el) {
310-
// Handle the novel status
311-
// Sadly some novels just state the status inside the summary...
312-
if (
313-
$(el)
314-
.find('strong')
315-
.text()
316-
.toLowerCase()
317-
.trim()
318-
.startsWith('status')
319-
) {
320-
$(el).find('strong').remove();
321-
const status = $(el).text().toLowerCase().trim();
322-
if (status.includes('on-going')) {
323-
novel.status = NovelStatus.Ongoing;
324-
} else if (status.includes('completed')) {
325-
novel.status = NovelStatus.Completed;
326-
} else if (status.includes('hiatus')) {
327-
novel.status = NovelStatus.OnHiatus;
328-
} else if (status.includes('cancelled')) {
329-
novel.status = NovelStatus.Cancelled;
330-
} else {
331-
novel.status = loadCheerio(el).text();
332-
}
333-
}
334-
// Handle the genres
335-
else if (
336-
$(el)
337-
.find('strong')
338-
.text()
339-
.toLowerCase()
340-
.trim()
341-
.startsWith('Category')
342-
) {
343-
$(el).find('strong').remove();
344-
// previously, list of '> span > a'
345-
novel.genres = $(el).text();
302+
$('.entry-content > table > tbody > tr > td > p').each(function (_i, el) {
303+
// Handle the novel status
304+
// Sadly some novels just state the status inside the summary...
305+
if (
306+
$(el).find('strong').text().toLowerCase().trim().startsWith('status')
307+
) {
308+
$(el).find('strong').remove();
309+
const status = $(el).text().toLowerCase().trim();
310+
if (status.includes('on-going')) {
311+
novel.status = NovelStatus.Ongoing;
312+
} else if (status.includes('completed')) {
313+
novel.status = NovelStatus.Completed;
314+
} else if (status.includes('hiatus')) {
315+
novel.status = NovelStatus.OnHiatus;
316+
} else if (status.includes('cancelled')) {
317+
novel.status = NovelStatus.Cancelled;
318+
} else {
319+
novel.status = loadCheerio(el).text();
346320
}
347-
},
348-
);
321+
}
322+
// Handle the genres
323+
else if (
324+
$(el).find('strong').text().toLowerCase().trim().startsWith('Category')
325+
) {
326+
$(el).find('strong').remove();
327+
// previously, list of '> span > a'
328+
novel.genres = $(el).text();
329+
}
330+
});
349331

350332
// Handle the author names
351333
// Both the author and the translator (if present) seem to be written out as links,
@@ -379,7 +361,7 @@ class ReLibraryPlugin implements Plugin.PluginBase {
379361
if (chap_path.startsWith(this.site)) {
380362
chap_path = chap_path.slice(this.site.length);
381363
}
382-
364+
383365
const epochStr = $(chap_el).attr('data-date');
384366
// if we can't get the released time (at least without any additional fetches), set it to null purposfully
385367
let epoch = null;
@@ -452,7 +434,7 @@ class ReLibraryPlugin implements Plugin.PluginBase {
452434
// edge cases like this.
453435
content.find('p:has(>code)+code:has(+p:has(>code))').each((_i, el) => {
454436
if (
455-
el.attribs.style.match(/(.*;)?font-family: 'Merriweather', serif;.*/)
437+
el.attribs.style.match(/(.*?;)?font-family: 'Merriweather', serif.*/)
456438
) {
457439
$(el.prev!!).remove();
458440
$(el.next!!).remove();

plugins/multisrc/lightnovelwp/template.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ class LightNovelWPPlugin implements Plugin.PluginBase {
329329
} else if (hasLockItemOnChapterNum) {
330330
isPaidChapter = false;
331331
}
332-
extractChapterNumber(data, tempChapter);
332+
extractChapterNumber(data.replace('🔒', '').trim(), tempChapter);
333333
} else if (isReadingChapterInfo === 2) {
334334
tempChapter.name =
335335
data
18 Bytes
Loading

public/static/multisrc/lightnovelwp/katreadingarchive/customCss.css

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,17 @@ blockquote, q {
44
color: var(--theme-onSurfaceVariant);
55
border-left: 4px solid var(--theme-outline);
66
quotes: none;
7-
}
7+
}
8+
9+
span.modern-footnotes-footnote__note {
10+
display: none;
11+
font-size: 80%;
12+
margin: 1em;
13+
padding: 1em;
14+
background: var(--theme-surfaceVariant);
15+
color: var(--theme-onSurfaceVariant);
16+
}
17+
18+
span.modern-footnotes-footnote__note.active {
19+
display: block;
20+
}
Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,9 @@
1-
// WORKAROUND: empty files currently break the download function!
1+
document.querySelectorAll('sup[data-mfn]').forEach(el => {
2+
const targetEl = `mfn-content-${el.getAttribute('data-mfn-post-scope')}-${el.getAttribute('data-mfn')}`;
3+
el.addEventListener('click', e => {
4+
e.preventDefault();
5+
e.stopPropagation();
6+
7+
document.querySelector(`#${targetEl}`).classList.toggle('active');
8+
});
9+
});
2.85 KB
Loading
377 Bytes
Loading
-862 Bytes
Loading
709 Bytes
Loading
-8.06 KB
Loading

0 commit comments

Comments
 (0)