Skip to content

Commit 08a1800

Browse files
小更新,能看书架了.
1 parent 5734650 commit 08a1800

File tree

3 files changed

+80
-27
lines changed

3 files changed

+80
-27
lines changed

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@
44

55
## 说明
66

7-
- 能用就行.
87
- 在使用**搜索**时,筛选功能不生效.
98
- 当筛选的**主题**的值为`推荐`时,**地区/进度**的值不生效.
9+
- 当筛选的**主题**的值为`书架`时,**地区/进度**的值不生效.
1010

1111
## 登录
1212

13-
您可以使用两种方式登录(不登录也能用):
13+
- 在 Rulia 插件设置中手动添加`authorization`值,重启Rulia进入插件即可.
1414

15-
1. 在 Rulia 插件设置中手动添加一个名为 `Cookie` 的 Header,将 Cookie 填入其中.
16-
2. 使用网页弹窗进行登录,网址填写 `https://www.mangacopy.com`,登录成功即可.
15+
## 下载
16+
17+
- 你可以点击[这里](https://github.com/LittleStar-OuO/plugin.CopyManga/releases)下载插件.

index.js

Lines changed: 67 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ let headers = {
44
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36 Edg/128.0.0.0'
55
}
66

7+
const userConfig = window.Rulia.getUserConfig()
8+
9+
let authorization = false;
10+
11+
if (userConfig.authorization) {
12+
authorization = userConfig.authorization;
13+
}
14+
715
async function setMangaListFilterOptions() {
816
const url = 'https://api.mangacopy.com/api/v3/h5/filter/comic/tags';
917
try {
@@ -27,20 +35,26 @@ async function setMangaListFilterOptions() {
2735
}]
2836
}
2937
]
38+
if (authorization) {
39+
result[0].options.push({
40+
label: '书架',
41+
value: 'bookshelf'
42+
})
43+
}
3044
const rawResponse = await window.Rulia.httpRequest({
3145
url: url,
3246
method: 'GET',
3347
payload: 'format=json&type=1',
3448
headers: headers
3549
});
3650
const response = JSON.parse(rawResponse);
37-
for (var item of response.results.theme) {
51+
for (let item of response.results.theme) {
3852
result[0].options.push({
3953
label: item.name,
4054
value: item.path_word
4155
})
4256
}
43-
for (var item of response.results.top) {
57+
for (let item of response.results.top) {
4458
result[1].options.push({
4559
label: item.name,
4660
value: item.path_word
@@ -52,7 +66,6 @@ async function setMangaListFilterOptions() {
5266
}
5367
}
5468

55-
5669
async function getMangaListByRecommend(page, pageSize) {
5770
const url =
5871
'https://api.mangacopy.com/api/v3/recs';
@@ -65,11 +78,43 @@ async function getMangaListByRecommend(page, pageSize) {
6578
headers: headers
6679
});
6780
const response = JSON.parse(rawResponse);
68-
var result = {
81+
let result = {
82+
list: []
83+
}
84+
for (let manga of response.results.list) {
85+
let comic = {
86+
title: manga.comic.name,
87+
url: 'https://www.mangacopy.com/comic/' + manga.comic.path_word,
88+
coverUrl: manga.comic.cover
89+
}
90+
result.list.push(comic);
91+
}
92+
window.Rulia.endWithResult(result);
93+
} catch (error) {
94+
window.Rulia.endWithException(error.message);
95+
}
96+
}
97+
98+
async function getMangaListByBookshelf(page, pageSize) {
99+
const url =
100+
'https://mangacopy.com/api/v3/member/collect/comics';
101+
try {
102+
const rawResponse = await window.Rulia.httpRequest({
103+
url: url,
104+
method: 'GET',
105+
payload: 'limit=' + pageSize + '&offset=' + ((page - 1) * pageSize) +
106+
'&free_type=1&ordering=-datetime_modifier',
107+
headers: {
108+
'authorization': authorization,
109+
'Platform': 2
110+
}
111+
});
112+
const response = JSON.parse(rawResponse);
113+
let result = {
69114
list: []
70115
}
71-
for (var manga of response.results.list) {
72-
var comic = {
116+
for (let manga of response.results.list) {
117+
let comic = {
73118
title: manga.comic.name,
74119
url: 'https://www.mangacopy.com/comic/' + manga.comic.path_word,
75120
coverUrl: manga.comic.cover
@@ -85,18 +130,20 @@ async function getMangaListByRecommend(page, pageSize) {
85130
async function getMangaListByCategory(page, pageSize, filterOptions) {
86131
if (filterOptions.theme == 'recommend') {
87132
return await getMangaListByRecommend(page, pageSize);
133+
} else if (filterOptions.theme == 'bookshelf') {
134+
return await getMangaListByBookshelf(page, pageSize);
88135
} else {
89136
const url = 'https://api.mangacopy.com/api/v3/comics';
90137
try {
91-
var theme = '';
92-
var top = '';
138+
let theme = '';
139+
let top = '';
93140
if (filterOptions.theme && filterOptions.theme != 0) {
94141
theme = '&theme=' + filterOptions.theme;
95142
}
96143
if (filterOptions.top && filterOptions.top != 0) {
97144
top = '&top=' + filterOptions.top;
98145
}
99-
var payload = '_update=true&format=json&free_type=1&limit=' + pageSize + '&offset=' + ((page - 1) *
146+
let payload = '_update=true&format=json&free_type=1&limit=' + pageSize + '&offset=' + ((page - 1) *
100147
pageSize) + '&ordering=popular' + theme + top;
101148
const rawResponse = await window.Rulia.httpRequest({
102149
url: url,
@@ -105,11 +152,11 @@ async function getMangaListByCategory(page, pageSize, filterOptions) {
105152
headers: headers
106153
})
107154
const response = JSON.parse(rawResponse);
108-
var result = {
155+
let result = {
109156
list: []
110157
}
111-
for (var manga of response.results.list) {
112-
var comic = {
158+
for (let manga of response.results.list) {
159+
let comic = {
113160
title: manga.name,
114161
url: 'https://www.mangacopy.com/comic/' + manga.path_word,
115162
coverUrl: manga.cover
@@ -135,11 +182,11 @@ async function getMangaListBySearching(page, pageSize, keyword) {
135182
headers: headers
136183
});
137184
const response = JSON.parse(rawResponse);
138-
var result = {
185+
let result = {
139186
list: []
140187
}
141-
for (var manga of response.results.list) {
142-
var comic = {
188+
for (let manga of response.results.list) {
189+
let comic = {
143190
title: manga.name,
144191
url: 'https://www.mangacopy.com/comic/' + manga.path_word,
145192
coverUrl: manga.cover
@@ -187,8 +234,8 @@ async function getMangaData(dataPageUrl) {
187234
});
188235
const chapterListResponse = JSON.parse(chapterListRawResponse);
189236

190-
for (var manga of chapterListResponse.results.list) {
191-
var comic = {
237+
for (let manga of chapterListResponse.results.list) {
238+
let comic = {
192239
title: '[' + manga.name + '][' + manga.datetime_created + ']',
193240
url: 'https://www.mangacopy.com/comic/' + seasonIdMatch[1] + '/chapter/' + manga.uuid
194241
}
@@ -204,16 +251,15 @@ async function getChapterImageList(chapterUrl) {
204251
const episodeIdMatchExp = /https?:\/\/www\.mangacopy\.com\/comic\/([a-zA-Z0-9_-]+)\/chapter\/([0-9a-f-]+)/;
205252
const episodeIdMatch = chapterUrl.match(episodeIdMatchExp);
206253
const url = 'https://api.mangacopy.com/api/v3/comic/' + episodeIdMatch[1] + '/chapter2/' + episodeIdMatch[2];
207-
208254
const rawResponse = await window.Rulia.httpRequest({
209255
url: url,
210256
method: 'GET',
211257
payload: 'format=json',
212258
headers: headers
213259
});
214260
const response = JSON.parse(rawResponse);
215-
var result = [];
216-
for (var i = 0; i < response.results.chapter.words.length; i++) {
261+
let result = [];
262+
for (let i = 0; i < response.results.chapter.words.length; i++) {
217263
result.push({
218264
url: response.results.chapter.contents[i].url.replace(/c800x/, 'c1500x'),
219265
index: response.results.chapter.words[i],
@@ -224,7 +270,7 @@ async function getChapterImageList(chapterUrl) {
224270
result.sort(function(a, b) {
225271
return a.index - b.index;
226272
});
227-
for (var i = 0; i < result.length; i++) {
273+
for (let i = 0; i < result.length; i++) {
228274
delete result[i].index;
229275
}
230276
window.Rulia.endWithResult(result);

package.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,14 @@
22
"name": "@rulia/CopyManga",
33
"title": "拷贝漫画",
44
"description": "拷贝漫画插件.",
5-
"version": "0.0.5",
5+
"version": "0.0.6",
66
"author": "LittleStar_OuO",
77
"tags": ["Copy", "Manga", "CopyManga"],
8-
"homepage": "https://github.com/LittleStar-OuO/plugin.CopyManga"
8+
"homepage": "https://github.com/LittleStar-OuO/plugin.CopyManga",
9+
"userConfig": {
10+
"authorization": {
11+
"displayName": "authorization",
12+
"description": "请使用“网页开发者工具”从网页的header中提取authorization,例如:Token a5822c5xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx54f"
13+
}
14+
}
915
}

0 commit comments

Comments
 (0)