@yyds-dudu/dsh-novel-reader 0.0.0-stage → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +153 -2
- package/client.js +1893 -0
- package/cordis.patch.yml +8 -0
- package/docs/DETAIL.md +1 -0
- package/docs/SOURCES.md +90 -0
- package/docs/preview.svg +15 -0
- package/docs/screenshot-1.png +0 -0
- package/docs/screenshot-2.png +0 -0
- package/docs/screenshot-3.png +0 -0
- package/docs/screenshot-online-reading.png +0 -0
- package/docs/screenshot-online-search.png +0 -0
- package/docs/screenshot-online-shelf.png +0 -0
- package/docs/screenshot-sources.png +0 -0
- package/icon.svg +7 -0
- package/index.js +197 -0
- package/lib/community-sources.js +2090 -0
- package/lib/html.js +52 -0
- package/lib/http.js +62 -0
- package/lib/legado.js +345 -0
- package/lib/sources/custom.js +76 -0
- package/lib/sources/daizhige.js +68 -0
- package/lib/sources/index.js +34 -0
- package/lib/sources/wikisource.js +244 -0
- package/locale/en.json +156 -0
- package/locale/zh.json +156 -0
- package/package.json +68 -4
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 维基文库(zh.wikisource.org)内置源。
|
|
3
|
+
* 内容是自由授权(多为 CC BY-SA 4.0 / 公版),适合作为合规内置源。
|
|
4
|
+
* 结构与 Legado 规则差异大(MediaWiki API),所以做成专用适配器而不是书源 JSON。
|
|
5
|
+
*/
|
|
6
|
+
import { decodeEntities } from '../html.js';
|
|
7
|
+
|
|
8
|
+
const API = 'https://zh.wikisource.org/w/api.php';
|
|
9
|
+
const SITE = 'https://zh.wikisource.org';
|
|
10
|
+
const MAX_TEXT = 1_500_000;
|
|
11
|
+
|
|
12
|
+
// 维基文库对匿名请求有速率限制(实测连续抓取会 429)。
|
|
13
|
+
// 用串行 + 间隔 + 指数退避把请求摊开,宁可慢也不要被封。
|
|
14
|
+
const MIN_INTERVAL_MS = 350;
|
|
15
|
+
let lastCallAt = 0;
|
|
16
|
+
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
17
|
+
|
|
18
|
+
/** 调 MediaWiki API:自动节流,429/5xx 退避重试。 */
|
|
19
|
+
async function api(params, attempt = 0) {
|
|
20
|
+
const wait = MIN_INTERVAL_MS - (Date.now() - lastCallAt);
|
|
21
|
+
if (wait > 0) await sleep(wait);
|
|
22
|
+
lastCallAt = Date.now();
|
|
23
|
+
|
|
24
|
+
const url = API + '?' + new URLSearchParams({ ...params, format: 'json', formatversion: '2' });
|
|
25
|
+
let res;
|
|
26
|
+
try {
|
|
27
|
+
res = await fetch(url, {
|
|
28
|
+
headers: {
|
|
29
|
+
'user-agent': 'dsh-novel-reader/1.1 (DSH plugin; local use)',
|
|
30
|
+
accept: 'application/json',
|
|
31
|
+
},
|
|
32
|
+
signal: AbortSignal.timeout(25_000),
|
|
33
|
+
});
|
|
34
|
+
} catch (error) {
|
|
35
|
+
if (attempt < 3) { await sleep(600 * (attempt + 1)); return api(params, attempt + 1); }
|
|
36
|
+
throw new Error('维基文库请求失败:' + (error && error.message ? error.message : error));
|
|
37
|
+
}
|
|
38
|
+
// 429(限流)与 503(过载)都退避重试
|
|
39
|
+
if (res.status === 429 || res.status === 503) {
|
|
40
|
+
if (attempt < 5) {
|
|
41
|
+
const retryAfter = Number(res.headers.get('retry-after') || 0);
|
|
42
|
+
await sleep(retryAfter > 0 ? retryAfter * 1000 : 1200 * (attempt + 1));
|
|
43
|
+
return api(params, attempt + 1);
|
|
44
|
+
}
|
|
45
|
+
throw new Error('维基文库限流了,请稍后再试(已重试 ' + attempt + ' 次)');
|
|
46
|
+
}
|
|
47
|
+
if (!res.ok) throw new Error('维基文库返回 HTTP ' + res.status);
|
|
48
|
+
try { return await res.json(); } catch { throw new Error('维基文库返回内容不是合法 JSON'); }
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** wikitext/HTML 里去掉模板与标签,得到可读文本。 */
|
|
52
|
+
function stripWiki(s) {
|
|
53
|
+
let out = String(s);
|
|
54
|
+
out = out.replace(/<style[\s\S]*?<\/style>/gi, '');
|
|
55
|
+
out = out.replace(/<script[\s\S]*?<\/script>/gi, '');
|
|
56
|
+
out = out.replace(/<sup[^>]*class="reference"[\s\S]*?<\/sup>/gi, ''); // 脚注
|
|
57
|
+
out = out.replace(/<[^>]+>/g, '');
|
|
58
|
+
out = decodeEntities(out);
|
|
59
|
+
out = out.replace(/&#\d+;/g, '');
|
|
60
|
+
return out;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** 把 HTML 正文拆成段落数组(含 wikitext 的 <p>、标题 div、行内 <br> 段落)。 */
|
|
64
|
+
function htmlParagraphs(html) {
|
|
65
|
+
const body = String(html)
|
|
66
|
+
.replace(/<style[\s\S]*?<\/style>/gi, '')
|
|
67
|
+
.replace(/<script[\s\S]*?<\/script>/gi, '')
|
|
68
|
+
.replace(/<sup[^>]*class="reference"[\s\S]*?<\/sup>/gi, '');
|
|
69
|
+
const parts = [];
|
|
70
|
+
// 1) 章节标题:wikitext 的 {{center|'''第X回…'''}} 渲染成 <div class="center"><b>…</b></div>
|
|
71
|
+
for (const m of body.matchAll(/<div[^>]*class="[^"]*center[^"]*"[^>]*>([\s\S]*?)<\/div>/gi)) {
|
|
72
|
+
const text = stripWiki(m[1]).replace(/\s+/g, ' ').trim();
|
|
73
|
+
if (text && /第[零一二三四五六七八九十百0-9]+[回章节卷部篇集]/.test(text)) parts.push('\u0000TITLE\u0000' + text);
|
|
74
|
+
}
|
|
75
|
+
// 2) 正文段落
|
|
76
|
+
for (const m of body.matchAll(/<p[^>]*>([\s\S]*?)<\/p>/gi)) {
|
|
77
|
+
// 段落里的 <br> 保留为换行(诗词、分行正文)
|
|
78
|
+
const raw = m[1].replace(/<br\s*\/?>/gi, '\n');
|
|
79
|
+
const text = stripWiki(raw).replace(/[ \t]+$/gm, '').trim();
|
|
80
|
+
if (text) parts.push(text);
|
|
81
|
+
}
|
|
82
|
+
if (parts.length) return parts.map((x) => x.startsWith('\u0000TITLE\u0000') ? x.slice(7) : x);
|
|
83
|
+
// 兜底:整段去标签
|
|
84
|
+
return stripWiki(body.replace(/<br\s*\/?>/gi, '\n')).split(/\n+/).map(x => x.trim()).filter(Boolean);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** 从子页面标题里取章节名,如 紅樓夢/第001回 → 第001回。 */
|
|
88
|
+
function chapterLabel(title) {
|
|
89
|
+
const i = String(title).lastIndexOf('/');
|
|
90
|
+
return i >= 0 ? title.slice(i + 1) : title;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** wikitext → 可读纯文本:去模板、去链接语法、去标题标记。 */
|
|
94
|
+
function wikitextToText(src) {
|
|
95
|
+
let s = String(src);
|
|
96
|
+
s = s.replace(/<ref[\s\S]*?<\/ref>/gi, '').replace(/<ref[^>]*\/>/gi, ''); // 脚注
|
|
97
|
+
s = s.replace(/<[^>]+>/g, ''); // 残留 HTML
|
|
98
|
+
s = s.replace(/-\{([^{}]*?)\}-/g, '$1'); // 语言转换标记 -{云}- → 云
|
|
99
|
+
s = s.replace(/\{\{~~\|([\s\S]*?)\}\}/g, '$1'); // {{~~|正文}} 是正文,不是模板
|
|
100
|
+
// {{center|'''第X回 回目'''}} 这类标题模板:现在这里被整段剥掉会导致回目丢失,
|
|
101
|
+
// 所以先把 center 模板里的内容取出来当成一行标题
|
|
102
|
+
s = s.replace(/\{\{\s*center\s*\|([\s\S]*?)\}\}/gi, (m, inner) => '\n' + inner.replace(/'{2,}/g, '').trim() + '\n');
|
|
103
|
+
// 剥模板:从内到外多轮,直到没有 {{ }}
|
|
104
|
+
for (let i = 0; i < 8; i++) {
|
|
105
|
+
const next = s.replace(/\{\{[^{}]*\}\}/g, '');
|
|
106
|
+
if (next === s) break;
|
|
107
|
+
s = next;
|
|
108
|
+
}
|
|
109
|
+
s = s.replace(/\[\[(?:[^\]|]*\|)?([^\]]*)\]\]/g, '$1'); // [[a|b]] → b
|
|
110
|
+
s = s.replace(/\[https?:\/\/\S+\s+([^\]]*)\]/g, '$1'); // [url 文本] → 文本
|
|
111
|
+
s = s.replace(/'''?/g, ''); // 粗斜体
|
|
112
|
+
s = s.replace(/^=+\s*(.*?)\s*=+$/gm, '$1'); // 标题
|
|
113
|
+
s = s.replace(/^----+$/gm, ''); // 水平线
|
|
114
|
+
s = s.replace(/^[*#:;]+\s?/gm, ''); // 列表符
|
|
115
|
+
s = decodeEntities(s);
|
|
116
|
+
return s
|
|
117
|
+
.split('\n')
|
|
118
|
+
.map((line) => line.replace(/^[\s\u3000]+|[\s\u3000]+$/g, ''))
|
|
119
|
+
.filter((line) => {
|
|
120
|
+
if (!line) return false;
|
|
121
|
+
// 导航行变体很多:『上一回 回目录 高續下一回』『原著第八十回 回目录 下一回』……
|
|
122
|
+
// 判定:整行不含正文特征,且去掉导航词与标点后几乎为空。
|
|
123
|
+
if (!/(回目录|上一回|下一回|目錄|目录)/.test(line)) return true;
|
|
124
|
+
const rest = line
|
|
125
|
+
.replace(/(回目录|上一回|下一回|目錄|目录)/g, '')
|
|
126
|
+
.replace(/原著|高續|高续|續|续|第[零一二三四五六七八九十百]+回/g, '')
|
|
127
|
+
.replace(/[\s\u3000·・、,,。.\-—_]+/g, '');
|
|
128
|
+
return rest.length > 0; // 只剩导航词 → 是导航行,丢掉
|
|
129
|
+
})
|
|
130
|
+
.join('\n');
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export const wikisource = {
|
|
134
|
+
id: 'wikisource',
|
|
135
|
+
name: '维基文库(自由授权)',
|
|
136
|
+
homepage: SITE,
|
|
137
|
+
|
|
138
|
+
async search(query, page) {
|
|
139
|
+
const data = await api({
|
|
140
|
+
action: 'query', list: 'search',
|
|
141
|
+
srsearch: query, srlimit: '20',
|
|
142
|
+
sroffset: String((Number(page) || 0) * 20),
|
|
143
|
+
srnamespace: '0',
|
|
144
|
+
});
|
|
145
|
+
const hits = (data.query && data.query.search) || [];
|
|
146
|
+
const items = hits.map((row) => ({
|
|
147
|
+
title: String(row.title || '').slice(0, 80),
|
|
148
|
+
url: SITE + '/wiki/' + encodeURIComponent(String(row.title || '').replace(/ /g, '_')),
|
|
149
|
+
note: '维基文库 · 自由授权',
|
|
150
|
+
snippet: stripWiki(row.snippet || '').replace(/\s+/g, ' ').trim().slice(0, 120),
|
|
151
|
+
}));
|
|
152
|
+
return { total: Number((data.query && data.query.searchinfo && data.query.searchinfo.totalhits) || items.length), page: Number(page) || 0, items };
|
|
153
|
+
},
|
|
154
|
+
|
|
155
|
+
/** 目录:找「书名/第NN回」这类子页面;没有子页就当整本一页。 */
|
|
156
|
+
async chapters(url, hint) {
|
|
157
|
+
const title = decodeURIComponent(String(url).split('/wiki/')[1] || '').replace(/_/g, ' ');
|
|
158
|
+
if (!title) throw new Error('无法从地址解析书名');
|
|
159
|
+
// allpages 单次最多 500 条,大部头要顺着 continue 取完
|
|
160
|
+
const pages = [];
|
|
161
|
+
let cont = null;
|
|
162
|
+
for (let round = 0; round < 20; round++) {
|
|
163
|
+
const params = { action: 'query', list: 'allpages', apprefix: title + '/', aplimit: '500', apnamespace: '0' };
|
|
164
|
+
if (cont) params.apcontinue = cont;
|
|
165
|
+
let data = null;
|
|
166
|
+
try { data = await api(params); } catch { data = null; }
|
|
167
|
+
if (!data) break;
|
|
168
|
+
for (const p of (data.query && data.query.allpages) || []) {
|
|
169
|
+
const t = String(p.title || '');
|
|
170
|
+
if (t.startsWith(title + '/')) pages.push(t);
|
|
171
|
+
}
|
|
172
|
+
cont = data.continue && data.continue.apcontinue;
|
|
173
|
+
if (!cont) break;
|
|
174
|
+
}
|
|
175
|
+
if (pages.length >= 2) {
|
|
176
|
+
// 子页面存在:按自然顺序(第001回、第002回…)排
|
|
177
|
+
pages.sort((a, b) => a.localeCompare(b, 'zh-Hans-CN', { numeric: true }));
|
|
178
|
+
return {
|
|
179
|
+
title: (hint && hint.title) || title,
|
|
180
|
+
author: (hint && hint.author) || '',
|
|
181
|
+
chapters: pages.map((t) => ({
|
|
182
|
+
title: chapterLabel(t),
|
|
183
|
+
url: SITE + '/wiki/' + encodeURIComponent(t.replace(/ /g, '_')),
|
|
184
|
+
})),
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
// 没有子页面:整本当一章
|
|
188
|
+
return {
|
|
189
|
+
title: (hint && hint.title) || title,
|
|
190
|
+
author: (hint && hint.author) || '',
|
|
191
|
+
chapters: [{ title: title || '正文', url }],
|
|
192
|
+
};
|
|
193
|
+
},
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* 批量取正文:MediaWiki 一次可查多页,把 120 次请求压到几次,避免触发限流。
|
|
197
|
+
* @param {string[]} urls 章节地址
|
|
198
|
+
* @returns {Promise<Object<string,string>>} 地址 → 正文
|
|
199
|
+
*/
|
|
200
|
+
async contents(urls) {
|
|
201
|
+
const out = {};
|
|
202
|
+
const list = (urls || []).filter(Boolean);
|
|
203
|
+
const titleOf = (u) => decodeURIComponent(String(u).split('/wiki/')[1] || '').replace(/_/g, ' ');
|
|
204
|
+
// 每批 20 个标题(MediaWiki titles 上限 50,留余量)
|
|
205
|
+
for (let i = 0; i < list.length; i += 20) {
|
|
206
|
+
const batch = list.slice(i, i + 20);
|
|
207
|
+
const titles = batch.map(titleOf).join('|');
|
|
208
|
+
let data;
|
|
209
|
+
try {
|
|
210
|
+
data = await api({ action: 'query', prop: 'revisions', rvprop: 'content', rvslots: 'main', titles });
|
|
211
|
+
} catch (error) {
|
|
212
|
+
// 批量失败就退回逐章,保证功能可用
|
|
213
|
+
for (const u of batch) {
|
|
214
|
+
try { const one = await this.content(u); out[u] = one.text; } catch { /* 跳过失败章 */ }
|
|
215
|
+
}
|
|
216
|
+
continue;
|
|
217
|
+
}
|
|
218
|
+
const pages = (data && data.query && data.query.pages) || [];
|
|
219
|
+
for (const page of pages) {
|
|
220
|
+
const url = SITE + '/wiki/' + encodeURIComponent(String(page.title || '').replace(/ /g, '_'));
|
|
221
|
+
const raw = page.revisions && page.revisions[0] && page.revisions[0].slots
|
|
222
|
+
&& page.revisions[0].slots.main && page.revisions[0].slots.main.content;
|
|
223
|
+
if (!raw) continue;
|
|
224
|
+
const text = wikitextToText(raw).slice(0, MAX_TEXT);
|
|
225
|
+
if (text.length >= 20) out[url] = text;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
return out;
|
|
229
|
+
},
|
|
230
|
+
|
|
231
|
+
async content(url) {
|
|
232
|
+
const title = decodeURIComponent(String(url).split('/wiki/')[1] || '').replace(/_/g, ' ');
|
|
233
|
+
if (!title) throw new Error('无法从地址解析页面名');
|
|
234
|
+
const data = await api({ action: 'parse', page: title, prop: 'text', disableeditsection: '1', disabletoc: '1' });
|
|
235
|
+
const html = data && data.parse && data.parse.text;
|
|
236
|
+
if (!html) throw new Error('维基文库没有返回正文');
|
|
237
|
+
const paragraphs = htmlParagraphs(html)
|
|
238
|
+
// 去掉导航行(回目录 / 上一回 / 下一回)
|
|
239
|
+
.filter((p) => !/^(回目录|上一回|下一回|目錄|目录)(\s*(回目录|上一回|下一回|目錄|目录))*$/.test(p));
|
|
240
|
+
const text = paragraphs.join('\n\n').slice(0, MAX_TEXT);
|
|
241
|
+
if (text.length < 20) throw new Error('这一页没有可读正文');
|
|
242
|
+
return { title: (data.parse && data.parse.title) || title, text };
|
|
243
|
+
},
|
|
244
|
+
};
|
package/locale/en.json
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
{
|
|
2
|
+
"meta": {
|
|
3
|
+
"title": "Novel Reader",
|
|
4
|
+
"description": "Search and read chapters online (Legado-compatible) or import a txt; read in a floating panel beside the input box, with a multi-book shelf and txt download."
|
|
5
|
+
},
|
|
6
|
+
"name": "Novel",
|
|
7
|
+
"import": "Import txt",
|
|
8
|
+
"importing": "Importing...",
|
|
9
|
+
"settings": "Settings",
|
|
10
|
+
"close": "Close",
|
|
11
|
+
"prevChapter": "Prev ch.",
|
|
12
|
+
"nextChapter": "Next ch.",
|
|
13
|
+
"prevPage": "‹",
|
|
14
|
+
"nextPage": "›",
|
|
15
|
+
"chapterPlaceholder": "Select a chapter",
|
|
16
|
+
"noBook": "No book imported",
|
|
17
|
+
"importHint": "Click Import txt or drop a .txt file here (UTF-8 / GBK)",
|
|
18
|
+
"settingsTitle": "Reading settings",
|
|
19
|
+
"followInput": "Follow input style",
|
|
20
|
+
"followInputHint": "Match the input box size, colors and font",
|
|
21
|
+
"panelStyleGroup": "Appearance",
|
|
22
|
+
"readerStyleGroup": "Reading area",
|
|
23
|
+
"panelGroup": "Settings panel style",
|
|
24
|
+
"readerGroup": "Reading area style",
|
|
25
|
+
"readerTextGroup": "Text & layout",
|
|
26
|
+
"readerSizeGroup": "Window size",
|
|
27
|
+
"chapterGroup": "Chapter detection",
|
|
28
|
+
"actionGroup": "Actions",
|
|
29
|
+
"panelTextGroup": "Panel text & font",
|
|
30
|
+
"panelSizeGroup": "Panel size",
|
|
31
|
+
"readerFollowLabel": "Reading area follows input",
|
|
32
|
+
"panelFollowLabel": "Panel follows input",
|
|
33
|
+
"panelFontSize": "Font size",
|
|
34
|
+
"panelLineHeight": "Line height",
|
|
35
|
+
"panelFontFamily": "Font",
|
|
36
|
+
"panelTextColor": "Panel text",
|
|
37
|
+
"panelBgColor": "Panel background",
|
|
38
|
+
"fontSize": "Font size",
|
|
39
|
+
"lineHeight": "Line height",
|
|
40
|
+
"fontFamily": "Font",
|
|
41
|
+
"textColor": "Text color",
|
|
42
|
+
"backgroundColor": "Background",
|
|
43
|
+
"bgOpacity": "Background opacity",
|
|
44
|
+
"windowWidth": "Panel width",
|
|
45
|
+
"windowHeight": "Panel height",
|
|
46
|
+
"customChapterRegex": "Chapter regex",
|
|
47
|
+
"borderStyleGroup": "Border",
|
|
48
|
+
"borderRadius": "Corner radius",
|
|
49
|
+
"borderVisible": "Show border",
|
|
50
|
+
"readerBorderGroup": "Reading area border",
|
|
51
|
+
"panelBorderGroup": "Settings panel border",
|
|
52
|
+
"pin": "Pin open",
|
|
53
|
+
"unpin": "Unpin",
|
|
54
|
+
"profileGroup": "Saved profiles",
|
|
55
|
+
"profileName": "Profile name",
|
|
56
|
+
"profileSave": "Save current",
|
|
57
|
+
"profileSelect": "Apply",
|
|
58
|
+
"profileDelete": "Delete",
|
|
59
|
+
"profileNone": "No saved profiles yet",
|
|
60
|
+
"profileSaved": "Saved: {name}",
|
|
61
|
+
"profileDeleted": "Deleted: {name}",
|
|
62
|
+
"profileApplied": "Applied: {name}",
|
|
63
|
+
"profileEmptyName": "Enter a profile name first",
|
|
64
|
+
"profileConfirmDelete": "Delete profile \"{name}\"?",
|
|
65
|
+
"regexHint": "One regex per line; empty uses built-in rules",
|
|
66
|
+
"reset": "Reset",
|
|
67
|
+
"resetPos": "Reset position",
|
|
68
|
+
"done": "Done",
|
|
69
|
+
"chapterCount": "ch",
|
|
70
|
+
"page": "p",
|
|
71
|
+
"noChapters": "No chapter detected; reading the whole file as one",
|
|
72
|
+
"decodeError": "Cannot decode this file (tried UTF-8 and GBK)",
|
|
73
|
+
"importFailed": "Import failed",
|
|
74
|
+
"byteUnavailable": "Browser cannot read raw bytes and UTF-8 decoding failed. Re-save the file as UTF-8.",
|
|
75
|
+
"styleTip": "Click 📖 to open · Mouse out closes · Click again to reopen · Drag the bar to move · Drop a .txt to import",
|
|
76
|
+
"resizeHint": "Drag the window edge to resize; changes are saved automatically",
|
|
77
|
+
"reopenHint": "Book data was cleared by the browser; please re-import the same file to resume.",
|
|
78
|
+
"imported": "Imported: {name} · {chapters} chapters",
|
|
79
|
+
"searchTitle": "Find books",
|
|
80
|
+
"searchPlaceholder": "Title or keyword",
|
|
81
|
+
"searchButton": "Search",
|
|
82
|
+
"searching": "Searching…",
|
|
83
|
+
"searchEmpty": "Type a keyword and search. Built-in source is public-domain classics.",
|
|
84
|
+
"searchNoResult": "No results",
|
|
85
|
+
"manageSources": "Sources",
|
|
86
|
+
"sourceLabel": "Source",
|
|
87
|
+
"sourceDaizhige": "Daizhige (public domain)",
|
|
88
|
+
"shelfTitle": "Bookshelf",
|
|
89
|
+
"shelfEmpty": "No books yet. Search online or import a .txt.",
|
|
90
|
+
"openBook": "Open",
|
|
91
|
+
"download": "Download txt",
|
|
92
|
+
"deleteBook": "Delete",
|
|
93
|
+
"back": "Back",
|
|
94
|
+
"sourcesTitle": "Sources",
|
|
95
|
+
"sourcesHint": "JSON array: custom source (name/search.url/search.item/book.content) or Legado source (bookSourceName/searchUrl/ruleSearch/ruleToc/ruleContent). Pure rules only; @js:/<js>/XPath unsupported. Built-in Daizhige and Wikisource need no setup; see docs/SOURCES.md for picking community sources.",
|
|
96
|
+
"sourcesSave": "Save sources",
|
|
97
|
+
"sourcesSaved": "Saved {count} custom source(s)",
|
|
98
|
+
"sourcesInvalid": "Invalid JSON",
|
|
99
|
+
"importBook": "Import",
|
|
100
|
+
"importingBook": "Downloading…",
|
|
101
|
+
"serverUnreachable": "Cannot reach local service. Is the plugin host running?",
|
|
102
|
+
"bookImported": "Imported: {title}",
|
|
103
|
+
"bookTruncated": " (text truncated)",
|
|
104
|
+
"confirmDeleteBook": "Delete \"{title}\"? The local text will be removed too.",
|
|
105
|
+
"currentReading": "Reading",
|
|
106
|
+
"healthRun": "🩺 Check",
|
|
107
|
+
"healthBusy": "Checking…",
|
|
108
|
+
"healthProgress": "Checking {done}/{total}",
|
|
109
|
+
"healthDone": "Checked: {ok}/{total} available",
|
|
110
|
+
"stopLabel": "⏹ Stop",
|
|
111
|
+
"searchFrom": "From: {name}",
|
|
112
|
+
"unknownSource": "unknown source",
|
|
113
|
+
"searchContinue": "Search other sources →",
|
|
114
|
+
"searchContinueShort": "Search again",
|
|
115
|
+
"searchStopped": "Stopped",
|
|
116
|
+
"searchProgress": "Searching: {name} ({i}/{n})",
|
|
117
|
+
"searchAllFailed": "Tried {n} sources, none matched \"{q}\"",
|
|
118
|
+
"noSources": "No available sources",
|
|
119
|
+
"fetchingAll": "Fetching all chapters and downloading txt… (delete the book in the shelf to abort)",
|
|
120
|
+
"importedAndDownloaded": "Imported and downloaded: {name}.txt",
|
|
121
|
+
"importDownloadFailed": "Added to shelf, but the automatic download failed: {msg}",
|
|
122
|
+
"downloadedOk": "Downloaded: {name}.txt",
|
|
123
|
+
"downloadFailed": "Download failed: {msg}",
|
|
124
|
+
"deletedDownloadStopped": "Deleted; download stopped",
|
|
125
|
+
"deletedOne": "Deleted",
|
|
126
|
+
"deleteFailed": "Delete failed: {msg}",
|
|
127
|
+
"downloadStopped": "Download stopped",
|
|
128
|
+
"downloadingShelf": "⏳ Downloading",
|
|
129
|
+
"sourcesManageTitle": "Source management",
|
|
130
|
+
"sourceAdd": "+ New",
|
|
131
|
+
"sourceAddTitle": "New source",
|
|
132
|
+
"sourceEditTitle": "Edit source",
|
|
133
|
+
"saveLabel": "Save",
|
|
134
|
+
"sourceEditorHint": "Paste a Legado (reading3) source JSON (object or array). Rules only; @js:, <js>, java.* and XPath are rejected.",
|
|
135
|
+
"sourcesSummary": "Built-in {b} · Community {c} (✔{ok} OK) · Custom {n}",
|
|
136
|
+
"sourcesBuiltinGroup": "Built-in sources (read-only)",
|
|
137
|
+
"sourcesBuiltinTag": "Licensed content",
|
|
138
|
+
"sourcesCustomGroup": "Custom sources (editable)",
|
|
139
|
+
"sourcesCustomEmpty": "No custom sources yet. Click “+ New” to add one.",
|
|
140
|
+
"sourcesCommunityGroup": "Community sources ({n}, disable or delete)",
|
|
141
|
+
"sourceDisabledTag": " · disabled",
|
|
142
|
+
"sourceDisable": "Disable",
|
|
143
|
+
"sourceEnable": "Enable",
|
|
144
|
+
"editLabel": "Edit",
|
|
145
|
+
"deleteLabel": "Delete",
|
|
146
|
+
"sourceNameFallback": "Source {n}",
|
|
147
|
+
"sourceSaved": "Saved {n} custom source(s)",
|
|
148
|
+
"sourceSaveFailed": "Save failed: {msg}",
|
|
149
|
+
"sourceDeleted": "Deleted: {name}",
|
|
150
|
+
"confirmDeleteSource": "Delete source \"{name}\"?",
|
|
151
|
+
"confirmDeleteCommunity": "Delete community source \"{name}\"?",
|
|
152
|
+
"loadingChapter": "Loading this chapter…",
|
|
153
|
+
"reloadChapter": "Reload chapter",
|
|
154
|
+
"onlineTag": " · online",
|
|
155
|
+
"wordsWan": "0k words"
|
|
156
|
+
}
|
package/locale/zh.json
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
{
|
|
2
|
+
"meta": {
|
|
3
|
+
"title": "小说阅读器",
|
|
4
|
+
"description": "在线找书/按章阅读(兼容阅读3书源)或导入 txt,在输入框旁的浮动窗口里阅读;支持多本书书架与 txt 下载。"
|
|
5
|
+
},
|
|
6
|
+
"name": "小说",
|
|
7
|
+
"import": "导入 txt",
|
|
8
|
+
"importing": "导入中…",
|
|
9
|
+
"settings": "设置",
|
|
10
|
+
"close": "收起",
|
|
11
|
+
"prevChapter": "上一章",
|
|
12
|
+
"nextChapter": "下一章",
|
|
13
|
+
"prevPage": "‹",
|
|
14
|
+
"nextPage": "›",
|
|
15
|
+
"chapterPlaceholder": "选择章节",
|
|
16
|
+
"noBook": "尚未导入小说",
|
|
17
|
+
"importHint": "点击「导入 txt」或把 .txt 文件拖到这里(支持 UTF-8 / GBK)",
|
|
18
|
+
"settingsTitle": "阅读设置",
|
|
19
|
+
"followInput": "跟随输入框样式",
|
|
20
|
+
"followInputHint": "自动匹配输入框的尺寸、配色和字体",
|
|
21
|
+
"panelStyleGroup": "外观",
|
|
22
|
+
"readerStyleGroup": "阅读区域",
|
|
23
|
+
"panelGroup": "设置面板样式",
|
|
24
|
+
"readerGroup": "阅读区样式",
|
|
25
|
+
"readerTextGroup": "阅读区文字与排版",
|
|
26
|
+
"readerSizeGroup": "阅读区尺寸",
|
|
27
|
+
"chapterGroup": "章节识别",
|
|
28
|
+
"actionGroup": "操作",
|
|
29
|
+
"panelTextGroup": "面板文字与字体",
|
|
30
|
+
"panelSizeGroup": "面板尺寸",
|
|
31
|
+
"readerFollowLabel": "阅读区跟随输入框",
|
|
32
|
+
"panelFollowLabel": "面板跟随输入框",
|
|
33
|
+
"panelFontSize": "字号",
|
|
34
|
+
"panelLineHeight": "行距",
|
|
35
|
+
"panelFontFamily": "字体",
|
|
36
|
+
"panelTextColor": "面板文字颜色",
|
|
37
|
+
"panelBgColor": "面板背景颜色",
|
|
38
|
+
"fontSize": "字号",
|
|
39
|
+
"lineHeight": "行距",
|
|
40
|
+
"fontFamily": "字体",
|
|
41
|
+
"textColor": "文字颜色",
|
|
42
|
+
"backgroundColor": "背景颜色",
|
|
43
|
+
"bgOpacity": "背景透明度",
|
|
44
|
+
"windowWidth": "面板宽度",
|
|
45
|
+
"windowHeight": "面板高度",
|
|
46
|
+
"customChapterRegex": "章节识别正则",
|
|
47
|
+
"borderStyleGroup": "窗口边框",
|
|
48
|
+
"borderRadius": "圆角大小",
|
|
49
|
+
"borderVisible": "显示边框",
|
|
50
|
+
"readerBorderGroup": "阅读区边框",
|
|
51
|
+
"panelBorderGroup": "设置面板边框",
|
|
52
|
+
"pin": "钉住常开",
|
|
53
|
+
"unpin": "取消钉住",
|
|
54
|
+
"profileGroup": "已保存配置",
|
|
55
|
+
"profileName": "配置名称",
|
|
56
|
+
"profileSave": "保存当前配置",
|
|
57
|
+
"profileSelect": "应用",
|
|
58
|
+
"profileDelete": "删除",
|
|
59
|
+
"profileNone": "暂无保存的配置",
|
|
60
|
+
"profileSaved": "已保存:{name}",
|
|
61
|
+
"profileDeleted": "已删除:{name}",
|
|
62
|
+
"profileApplied": "已应用:{name}",
|
|
63
|
+
"profileEmptyName": "请先输入配置名称",
|
|
64
|
+
"profileConfirmDelete": "确定删除配置「{name}」?",
|
|
65
|
+
"regexHint": "每行一条正则;留空用内置规则",
|
|
66
|
+
"reset": "恢复默认",
|
|
67
|
+
"resetPos": "重置位置",
|
|
68
|
+
"done": "完成",
|
|
69
|
+
"chapterCount": "章",
|
|
70
|
+
"page": "页",
|
|
71
|
+
"noChapters": "未识别到章节,整本作为一章阅读",
|
|
72
|
+
"decodeError": "无法解码该文件(已尝试 UTF-8 与 GBK)",
|
|
73
|
+
"importFailed": "导入失败",
|
|
74
|
+
"byteUnavailable": "浏览器无法读取原始字节且 UTF-8 解码失败,请将文件另存为 UTF-8。",
|
|
75
|
+
"styleTip": "点击 📖 打开 · 鼠标移出收起 · 再点图标重开 · 拖动底部条移动 · 拖入 .txt 导入",
|
|
76
|
+
"resizeHint": "拖动窗口边缘可调整大小,改动会自动保存",
|
|
77
|
+
"reopenHint": "书籍正文已被浏览器清理,请重新导入同一文件继续阅读。",
|
|
78
|
+
"imported": "已导入:{name} · 共 {chapters} 章",
|
|
79
|
+
"searchTitle": "找书",
|
|
80
|
+
"searchPlaceholder": "书名或关键词",
|
|
81
|
+
"searchButton": "搜索",
|
|
82
|
+
"searching": "搜索中…",
|
|
83
|
+
"searchEmpty": "输入关键词后搜索;内置源为公版古典文献。",
|
|
84
|
+
"searchNoResult": "没有找到结果",
|
|
85
|
+
"manageSources": "书源",
|
|
86
|
+
"sourceLabel": "书源",
|
|
87
|
+
"sourceDaizhige": "殆知阁(公版古典)",
|
|
88
|
+
"shelfTitle": "书架",
|
|
89
|
+
"shelfEmpty": "书架还是空的,去「找书」或导入一份 txt。",
|
|
90
|
+
"openBook": "打开",
|
|
91
|
+
"download": "下载 txt",
|
|
92
|
+
"deleteBook": "删除",
|
|
93
|
+
"back": "返回",
|
|
94
|
+
"sourcesTitle": "书源管理",
|
|
95
|
+
"sourcesHint": "JSON 数组:自定义源(name/search.url/search.item/book.content)或阅读3 书源(bookSourceName/searchUrl/ruleSearch/ruleToc/ruleContent)。仅支持纯规则,含 @js:/<js>/XPath 的源无法运行。内置的殆知阁与维基文库无需配置;社区书源择优方法见 docs/SOURCES.md。",
|
|
96
|
+
"sourcesSave": "保存书源",
|
|
97
|
+
"sourcesSaved": "已保存 {count} 个自定义书源",
|
|
98
|
+
"sourcesInvalid": "JSON 格式有误",
|
|
99
|
+
"importBook": "导入",
|
|
100
|
+
"importingBook": "下载中…",
|
|
101
|
+
"serverUnreachable": "连不上本地服务,请确认插件宿主已运行。",
|
|
102
|
+
"bookImported": "已导入:{title}",
|
|
103
|
+
"bookTruncated": "(正文过长已截断)",
|
|
104
|
+
"confirmDeleteBook": "确定删除「{title}」?本地正文也会一起删除。",
|
|
105
|
+
"currentReading": "在读",
|
|
106
|
+
"healthRun": "🩺 体检",
|
|
107
|
+
"healthBusy": "体检中…",
|
|
108
|
+
"healthProgress": "体检中 {done}/{total}",
|
|
109
|
+
"healthDone": "体检完成:{ok}/{total} 可用",
|
|
110
|
+
"stopLabel": "⏹ 停止",
|
|
111
|
+
"searchFrom": "来自:{name}",
|
|
112
|
+
"unknownSource": "未知书源",
|
|
113
|
+
"searchContinue": "继续搜索其他书源 →",
|
|
114
|
+
"searchContinueShort": "继续搜索",
|
|
115
|
+
"searchStopped": "已停止",
|
|
116
|
+
"searchProgress": "正在搜索:{name}({i}/{n})",
|
|
117
|
+
"searchAllFailed": "已试过 {n} 个书源,都没有找到「{q}」",
|
|
118
|
+
"noSources": "没有可用的书源",
|
|
119
|
+
"fetchingAll": "正在抓取全部章节并下载 txt…(可在书架点 ✕ 删除来中止)",
|
|
120
|
+
"importedAndDownloaded": "已导入并下载:{name}.txt",
|
|
121
|
+
"importDownloadFailed": "已加入书架,但自动下载失败:{msg}",
|
|
122
|
+
"downloadedOk": "已下载:{name}.txt",
|
|
123
|
+
"downloadFailed": "下载失败:{msg}",
|
|
124
|
+
"deletedDownloadStopped": "已删除,下载任务已停止",
|
|
125
|
+
"deletedOne": "已删除",
|
|
126
|
+
"deleteFailed": "删除失败:{msg}",
|
|
127
|
+
"downloadStopped": "已停止下载",
|
|
128
|
+
"downloadingShelf": "⏳ 下载中",
|
|
129
|
+
"sourcesManageTitle": "书源管理",
|
|
130
|
+
"sourceAdd": "+ 新增",
|
|
131
|
+
"sourceAddTitle": "新增书源",
|
|
132
|
+
"sourceEditTitle": "编辑书源",
|
|
133
|
+
"saveLabel": "保存",
|
|
134
|
+
"sourceEditorHint": "粘贴阅读3 / Legado 书源 JSON(单个对象或数组)。仅支持纯规则;含 @js: / <js> / java.* / XPath 的会报错。",
|
|
135
|
+
"sourcesSummary": "内置 {b} · 社区 {c}(✔{ok} 可用)· 自定义 {n}",
|
|
136
|
+
"sourcesBuiltinGroup": "内置书源(不可删除)",
|
|
137
|
+
"sourcesBuiltinTag": "合规内容源",
|
|
138
|
+
"sourcesCustomGroup": "自定义书源(可编辑/删除)",
|
|
139
|
+
"sourcesCustomEmpty": "还没有自定义书源,点右上角「+ 新增」导入",
|
|
140
|
+
"sourcesCommunityGroup": "社区书源({n},可停用/删除)",
|
|
141
|
+
"sourceDisabledTag": " · 已停用",
|
|
142
|
+
"sourceDisable": "停用",
|
|
143
|
+
"sourceEnable": "启用",
|
|
144
|
+
"editLabel": "编辑",
|
|
145
|
+
"deleteLabel": "删除",
|
|
146
|
+
"sourceNameFallback": "书源 {n}",
|
|
147
|
+
"sourceSaved": "已保存,共 {n} 个自定义书源",
|
|
148
|
+
"sourceSaveFailed": "保存失败:{msg}",
|
|
149
|
+
"sourceDeleted": "已删除:{name}",
|
|
150
|
+
"confirmDeleteSource": "确定删除书源「{name}」?",
|
|
151
|
+
"confirmDeleteCommunity": "确定删除社区书源「{name}」?",
|
|
152
|
+
"loadingChapter": "正在加载本章…",
|
|
153
|
+
"reloadChapter": "重新加载本章",
|
|
154
|
+
"onlineTag": " · 在线",
|
|
155
|
+
"wordsWan": " 万字"
|
|
156
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,70 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yyds-dudu/dsh-novel-reader",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.2.0",
|
|
4
|
+
"description": "DSH 小说阅读器:在输入框旁悬浮一个轻量小说阅读面板,内置殆知阁与维基文库两个合规书源、50 个社区书源并支持自建书源;找书自动多源搜索、无需选源,点导入即抓全章并下载 txt,支持按章在线阅读、多本书书架、章节识别跳转、点击翻页、悬浮/钉住、样式自定义、阅读进度记忆与多套样式配置。",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"dsh-plugin",
|
|
9
|
+
"deepseek-harness",
|
|
10
|
+
"novel-reader",
|
|
11
|
+
"online-books",
|
|
12
|
+
"小说阅读器",
|
|
13
|
+
"在线找书",
|
|
14
|
+
"阅读3书源",
|
|
15
|
+
"在线阅读",
|
|
16
|
+
"摸鱼"
|
|
17
|
+
],
|
|
18
|
+
"homepage": "https://github.com/yyds-dudu/dsh-novel-reader#readme",
|
|
19
|
+
"bugs": {
|
|
20
|
+
"url": "https://github.com/yyds-dudu/dsh-novel-reader/issues"
|
|
21
|
+
},
|
|
22
|
+
"repository": {
|
|
23
|
+
"type": "git",
|
|
24
|
+
"url": "git+https://github.com/yyds-dudu/dsh-novel-reader.git"
|
|
25
|
+
},
|
|
26
|
+
"publishConfig": {
|
|
27
|
+
"access": "public",
|
|
28
|
+
"registry": "https://registry.npmjs.org/"
|
|
29
|
+
},
|
|
30
|
+
"engines": {
|
|
31
|
+
"node": ">=22"
|
|
32
|
+
},
|
|
33
|
+
"exports": {
|
|
34
|
+
".": "./index.js",
|
|
35
|
+
"./client": "./client.js",
|
|
36
|
+
"./locale/*.json": "./locale/*.json",
|
|
37
|
+
"./icon": "./icon.svg"
|
|
38
|
+
},
|
|
39
|
+
"files": [
|
|
40
|
+
"index.js",
|
|
41
|
+
"client.js",
|
|
42
|
+
"lib",
|
|
43
|
+
"cordis.patch.yml",
|
|
44
|
+
"locale/*.json",
|
|
45
|
+
"icon.svg",
|
|
46
|
+
"README.md",
|
|
47
|
+
"docs"
|
|
48
|
+
],
|
|
49
|
+
"peerDependencies": {
|
|
50
|
+
"@deepseek-ai/cordis": "^4.0.2",
|
|
51
|
+
"@deepseek-ai/dsh-client-ui-conversation": "^0.1.5-rc.3 || ^0.2.0-rc.1",
|
|
52
|
+
"react": "^18.2.0"
|
|
53
|
+
},
|
|
54
|
+
"dsh": {
|
|
55
|
+
"bundle": {
|
|
56
|
+
"patch": "./cordis.patch.yml"
|
|
57
|
+
},
|
|
58
|
+
"client": {
|
|
59
|
+
"platform": "web",
|
|
60
|
+
"immediately": true,
|
|
61
|
+
"inject": [
|
|
62
|
+
"@deepseek-ai/dsh-client-ui-conversation"
|
|
63
|
+
]
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
"dependencies": {
|
|
67
|
+
"htmlparser2": "^10.1.0",
|
|
68
|
+
"dom-serializer": "^2.0.0"
|
|
69
|
+
}
|
|
70
|
+
}
|