Skip to content

Commit

Permalink
Develop (#6)
Browse files Browse the repository at this point in the history
* + Add image quality config.

* + Remove HTML tag in the search result.
  • Loading branch information
LancerComet authored Mar 28, 2024
1 parent 6634804 commit 6341f2b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 10 deletions.
31 changes: 22 additions & 9 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,13 @@ async function getMangaListBySearching (page: number, pageSize: number, keyword:
}

const result: IGetMangaListResult = {
list: response.data.list.map(item => ({
title: item.title,
url: `https://manga.bilibili.com/detail/mc${item.id}`,
coverUrl: item.vertical_cover + '@500w.jpg'
}))
list: response.data.list.map(item => {
return {
title: item.title.replace(/<.*?>/g, ''),
url: `https://manga.bilibili.com/detail/mc${item.id}`,
coverUrl: item.vertical_cover + '@500w.jpg'
}
})
}

window.Rulia.endWithResult(result)
Expand Down Expand Up @@ -323,12 +325,23 @@ async function getChapterImageList (chapterUrl: string) {
*/
async function getImageUrl (path: string) {
// 'path' is in the form of '/bfs/manga/3a6b12f0f9d64a9a5401e0933087a060a022cec4.jpg'.
try {
const userConfig = window.Rulia.getUserConfig() ?? {}
const imageQuality = parseInt(userConfig.imageQuality)

let quality = '@1100w.jpg'
if (imageQuality === 1) {
quality = '@1500w.jpg'
} else if (imageQuality === 2) {
quality = '@1920w.jpg'
} else if (imageQuality === 3) {
quality = ''
}

const payload = {
urls: JSON.stringify([path + '@1100w.jpg'])
}
const payload = {
urls: JSON.stringify([path + quality])
}

try {
const rawResponse = await window.Rulia.httpRequest({
url: 'https://manga.bilibili.com/twirp/comic.v1.Comic/ImageToken?device=pc&platform=web',
method: 'POST',
Expand Down
8 changes: 7 additions & 1 deletion src/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,11 @@
"version": "<VERSION>",
"author": "LancerComet",
"tags": ["Bilibili", "Manga"],
"homepage": "https://github.com/RuliaReader/plugin.bilibili-manga"
"homepage": "https://github.com/RuliaReader/plugin.bilibili-manga",
"userConfig": {
"imageQuality": {
"displayName": "图片质量",
"description": "0 或不填:宽度 1100px;填 1:1500 px;填 2:1920px;填 3:原图."
}
}
}

0 comments on commit 6341f2b

Please sign in to comment.