Skip to content

Commit 88b0e93

Browse files
committed
修改用户
1 parent 2c8c2d8 commit 88b0e93

10 files changed

Lines changed: 202 additions & 11 deletions

Code/maxos-23uswx.org.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ plugin.exports = class Plugin implements BookSource {
4545
* 静态属性 PLUGIN_FILE_URL 必填
4646
* 插件http、https链接, 如: http://example.com/plugin-template.js
4747
*/
48-
public static readonly PLUGIN_FILE_URL: string = 'https://raw.kkgithub.com/MaxOSSC/ReadCat-BookSource/main/Plugin/maxos-23uswx.org.ts.js';
48+
public static readonly PLUGIN_FILE_URL: string = 'https://raw.kkgithub.com/Maxthos/ReadCat-BookSource/main/Plugin/maxos-23uswx.org.ts.js';
4949
/**
5050
* 静态属性 BASE_URL 必填
5151
* 插件请求目标链接
@@ -180,7 +180,7 @@ plugin.exports = class Plugin implements BookSource {
180180
async getTextContent(chapter: Chapter): Promise<string[]> {
181181
const { body } = await this.request.get(chapter.url);
182182
const $ = this.cheerio(body);
183-
$('#content div').remove('div');
183+
$('#content div').remove();
184184
return $('#content').html().split('<br>').filter(t => t.trim());
185185
}
186186

Code/maxos-mayitxt.org.ts

Lines changed: 191 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,191 @@
1+
/**
2+
* 文件编码: UTF-8(如不是UTF8编码可能会导致乱码或未知错误)
3+
* 禁止使用import、require导入模块
4+
* 若使用import * from *、import()、require()导入模块, 无法通过插件校验
5+
* import fs from 'fs';
6+
* import('fs').then().catch();
7+
* require('fs');
8+
*/
9+
plugin.exports = class Plugin implements BookSource {
10+
/**
11+
* 静态属性 ID 自动生成
12+
* 该值需符合正则表达式: [A-Za-z0-9_-]
13+
*/
14+
public static readonly ID: string = "RipYNVxhVR7aTH22P56gJ";
15+
/**
16+
* 静态属性 TYPE 必填
17+
* 插件类型
18+
* 值类型:
19+
* plugin.type.BOOK_SOURCE - 表示该插件为书源类
20+
* plugin.type.BOOK_STORE - 表示该插件为书城类
21+
*/
22+
public static readonly TYPE: number = plugin.type.BOOK_SOURCE;
23+
/**
24+
* 静态属性 GROUP 必填
25+
* 插件分组
26+
*/
27+
public static readonly GROUP: string = "👻MaxOS";
28+
/**
29+
* 静态属性 NAME 必填
30+
* 插件名称
31+
*/
32+
public static readonly NAME: string = "蚂蚁阅读";
33+
/**
34+
* 静态属性 VERSION 必填
35+
* 插件版本 用于显示
36+
*/
37+
public static readonly VERSION: string = "1.0.0";
38+
/**
39+
* 静态属性 VERSION_CODE 必填
40+
* 插件版本代码 用于比较本地插件与静态属性PLUGIN_FILE_URL所指插件的版本号
41+
*/
42+
public static readonly VERSION_CODE: number = 0;
43+
/**
44+
* 静态属性 PLUGIN_FILE_URL 必填
45+
* 插件http、https链接, 如: http://example.com/plugin-template.js
46+
*/
47+
public static readonly PLUGIN_FILE_URL: string = "";
48+
/**
49+
* 静态属性 BASE_URL 必填
50+
* 插件请求目标链接
51+
*/
52+
public static readonly BASE_URL: string = "http://www.mayitxt.org";
53+
/**
54+
* 静态属性 REQUIRE 可选
55+
* 要求用户填写的值
56+
*/
57+
public static readonly REQUIRE: Record<string, string> = {};
58+
private request: ReadCatRequest;
59+
private store: Store;
60+
private cheerio: CheerioModule.load;
61+
private nanoid: () => string;
62+
constructor(options: PluginConstructorOptions) {
63+
const { request, store, cheerio, nanoid } = options;
64+
/**
65+
* request
66+
* function get(url, config)
67+
* url: string 请求链接
68+
* config(可选): {
69+
* params(可选): { [key: string]: number | string | boolean } | URLSearchParams, 请求参数
70+
* headers(可选): { [key: string]: string }, 请求头
71+
* proxy(可选): boolean 是否开启代理,
72+
* charset(可选): string 字符集, 默认为自动获取, 当出现乱码时请指定字符集
73+
* urlencode(可选): string URL编码, 默认UTF8
74+
* maxRedirects(可选): number 最大重定向数, 为0时则禁止重定向
75+
* responseType(可选): 'arraybuffer' | 'text' | 'json' 响应体类型, 默认text
76+
* signal(可选): AbortSignal 中止信号
77+
* }
78+
* return: Promise<{ body, code, headers }>
79+
* function post(url, config)
80+
* url: string 请求链接
81+
* config(可选): {
82+
* params(可选): { [key: string]: number | string | boolean }, | URLSearchParams, 请求参数
83+
* headers(可选): { [key: string]: string }, 请求头
84+
* proxy(可选): boolean 是否开启代理
85+
* charset(可选): string 字符集, 默认为自动获取, 当出现乱码时请指定字符集
86+
* urlencode(可选): string URL编码, 默认UTF8
87+
* maxRedirects(可选): number 最大重定向数, 为0时则禁止重定向
88+
* responseType(可选): 'arraybuffer' | 'text' | 'json' 响应体类型, 默认text
89+
* signal(可选): AbortSignal 中止信号
90+
* }
91+
* return: Promise<{ body, code, headers }>
92+
*
93+
* body: 响应体
94+
* code: 响应码
95+
* headers: 响应头
96+
*/
97+
this.request = request;
98+
/**
99+
* 每个插件都自带仓库(最大存储4MB), 您可向该仓库设置、获取、删除值
100+
* store
101+
* function setStoreValue(key, value)
102+
* key: string,
103+
* value: any (JavaScript基本数据类型), 该值经过v8.serialize处理
104+
* return Promise<void>
105+
* function getStoreValue(key)
106+
* key: string
107+
* return Promise<any> (JavaScript基本数据类型)
108+
* function removeStoreValue(key)
109+
* key: string
110+
* return Promise<void>
111+
*/
112+
this.store = store;
113+
/**
114+
* function cheerio(html: string)
115+
* 该值是模块cheerio中的load方法, 用法 const $ = cheerio(HTMLString)
116+
* 文档: https://cheerio.nodejs.cn/docs/basics/loading#load
117+
*/
118+
this.cheerio = cheerio;
119+
/**
120+
* function nanoid
121+
* 获取21位随机字符串
122+
*/
123+
this.nanoid = nanoid;
124+
}
125+
// http://www.mayitxt.org/modules/article/search.php?q=%E5%AE%8C%E7%BE%8E%E4%B8%96%E7%95%8C&searchtype=all&s=17333194950446968473
126+
// http://www.mayitxt.org/modules/article/search.php?q=%E5%AE%8C%E7%BE%8E%E4%B8%96%E7%95%8C&searchtype=all&s=17333194950446968473
127+
async search(searchkey: string): Promise<SearchEntity[]> {
128+
const { body } = await this.request.get(
129+
`${Plugin.BASE_URL}/modules/article/search.php?q=${searchkey}&searchtype=all&s=17333194950446968473`
130+
);
131+
const $ = this.cheerio(body);
132+
const trs = $("tbody tr:nth-child(n+2)");
133+
console.log(trs.length);
134+
const results: SearchEntity[] = [];
135+
for (const tr of trs) {
136+
console.log(tr);
137+
const td = $(tr).find("td");
138+
const regex = /\/(\d+)_(\d+)\//;
139+
const match = $(td.get(2)).children("a").attr("href").match(regex);
140+
const fid = match[1];
141+
const bid = match[2];
142+
console.log(fid, bid);
143+
results.push({
144+
bookname: $(td.get(2)).children("a").text(),
145+
author: $(td.get(5)).text(),
146+
coverImageUrl: `${Plugin.BASE_URL}/files/article/image/${fid}/${bid}/${bid}s.jpg`,
147+
detailPageUrl: $(td.get(0)).children("a").attr("href"),
148+
latestChapterTitle: $(td.get(3)).text(),
149+
});
150+
}
151+
return results;
152+
}
153+
154+
async getDetail(detailPageUrl: string): Promise<DetailEntity> {
155+
const { body } = await this.request.get(detailPageUrl);
156+
const $ = this.cheerio(body);
157+
const bookname = $("#info > h1").text();
158+
const author = $("#info > p:nth-child(2) > a").text();
159+
const latestChapterTitle = $("#info > p:nth-child(5) > a").text();
160+
const coverImageUrl = $("#fmimg > img").attr("src");
161+
const intro = $("#intro").text();
162+
// console.log(detailPageUrl);
163+
const items = $("#list > dl > dd");
164+
const chapterList: Chapter[] = [];
165+
for (const item of items) {
166+
const a = $(item).children("a");
167+
chapterList.push({
168+
title: a.text(),
169+
url: Plugin.BASE_URL + a.attr("href"),
170+
});
171+
}
172+
return {
173+
bookname,
174+
author,
175+
latestChapterTitle,
176+
coverImageUrl,
177+
intro,
178+
chapterList,
179+
};
180+
}
181+
182+
async getTextContent(chapter: Chapter): Promise<string[]> {
183+
const { body } = await this.request.get(chapter.url);
184+
const $ = this.cheerio(body);
185+
$("#content div").remove("div");
186+
return $("#content")
187+
.html()
188+
.split("<br>")
189+
.filter((t) => t.trim());
190+
}
191+
};

Code/maxos-qijizuopin.com.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ plugin.exports = class Plugin implements BookSource {
4545
* 静态属性 PLUGIN_FILE_URL 必填
4646
* 插件http、https链接, 如: http://example.com/plugin-template.js
4747
*/
48-
public static readonly PLUGIN_FILE_URL: string = 'https://raw.kkgithub.com/MaxOSSC/ReadCat-BookSource/main/Plugin/maxos-qijizuopin.com.ts.js';
48+
public static readonly PLUGIN_FILE_URL: string = 'https://raw.kkgithub.com/Maxthos/ReadCat-BookSource/main/Plugin/maxos-qijizuopin.com.ts.js';
4949
/**
5050
* 静态属性 BASE_URL 必填
5151
* 插件请求目标链接
@@ -180,7 +180,7 @@ plugin.exports = class Plugin implements BookSource {
180180
async getTextContent(chapter: Chapter): Promise<string[]> {
181181
const { body } = await this.request.get(chapter.url);
182182
const $ = this.cheerio(body);
183-
const texts = $(".content > p").map((index, element) => $(element).text().trim()).get();
183+
const texts = $(".content > p").map((index, element) => $(element).text()).get();
184184
return texts;
185185
}
186186

Code/maxos-qu70.cc.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ plugin.exports = class Plugin implements BookSource {
4545
* 插件http、https链接, 如: http://example.com/plugin-template.js
4646
*/
4747
public static readonly PLUGIN_FILE_URL: string =
48-
"https://raw.kkgithub.com/MaxOSSC/ReadCat-BookSource/main/Plugin/maxos-qu70.cc.ts.js";
48+
"https://raw.kkgithub.com/Maxthos/ReadCat-BookSource/main/Plugin/maxos-qu70.cc.ts.js";
4949
/**
5050
* 静态属性 BASE_URL 必填
5151
* 插件请求目标链接

Code/maxos-xuanyge.info.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ plugin.exports = class Plugin implements BookSource {
4545
* 插件http、https链接, 如: http://example.com/plugin-template.js
4646
*/
4747
public static readonly PLUGIN_FILE_URL: string =
48-
"https://raw.kkgithub.com/MaxOSSC/ReadCat-BookSource/main/Plugin/maxos-uanyge.info.ts.js";
48+
"https://raw.kkgithub.com/Maxthos/ReadCat-BookSource/main/Plugin/maxos-uanyge.info.ts.js";
4949
/**
5050
* 静态属性 BASE_URL 必填
5151
* 插件请求目标链接

Code/maxos-xzmncy.com.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ plugin.exports = class Plugin implements BookSource {
4545
* 插件http、https链接, 如: http://example.com/plugin-template.js
4646
*/
4747
public static readonly PLUGIN_FILE_URL: string =
48-
"https://raw.kkgithub.com/MaxOSSC/ReadCat-BookSource/main/Plugin/maxos-xzmncy.com.ts.js";
48+
"https://raw.kkgithub.com/Maxthos/ReadCat-BookSource/main/Plugin/maxos-xzmncy.com.ts.js";
4949
/**
5050
* 静态属性 BASE_URL 必填
5151
* 插件请求目标链接

Plugin/maxos-23uswx.org.ts.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Plugin/maxos-qijizuopin.com.ts.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)