UNPKG

rsshub

Version:
54 lines (53 loc) 2.02 kB
import { t as rofetch } from "./ofetch-C3ts-Hud.mjs"; import { t as cache_default } from "./cache-BkqOokyU.mjs"; import { load } from "cheerio"; //#region lib/routes/freexcomic/book.ts const jjmhw = "http://www.jjmhw.cc"; const getLatestAddress = () => cache_default.tryGet("freexcomic:getLatestAddress", async () => { const $portal = load(await rofetch("https://www.freexcomic.com")); const $address = load(await rofetch(new URL($portal(".alert-btn").attr("href")).href.replace("http:", "https:"))); return $address("p.ta-c.mb10 a").toArray().map((item) => $address(item).attr("href")); }); const handler = async (ctx) => { const { id } = ctx.req.param(); const limit = Number(ctx.req.query("limit")) || 10; const addresses = await getLatestAddress(); const link = `${addresses[0]}book/${id}`; const $ = load(await rofetch(link)); const list = $("#detail-list-select > li > a").toArray().toReversed().slice(0, limit).map((item) => { const $item = $(item); return { title: $item.text(), link: new URL($item.attr("href"), addresses[Math.floor(Math.random() * addresses.length)]).href, guid: new URL($item.attr("href"), jjmhw).href }; }); const items = await Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => { const comicpage = load(await rofetch(item.link))(".comicpage"); comicpage.find("img").each((_, ele) => { ele.attribs.src = ele.attribs["data-original"]; }); item.description = comicpage.html(); return item; }))); return { title: `漫小肆 ${$("div.info > h1").text()}`, link, description: `漫小肆 ${$("div.info .content span span").text()}`, image: $(".banner_detail .cover img").attr("src"), item: items }; }; const route = { path: "/book/:id", example: "/freexcomic/book/90", parameters: { id: "漫画id,漫画主页的地址栏中" }, radar: [{ source: ["www.jjmhw.cc/book/:id"] }], name: "漫画更新", maintainers: ["junfengP"], handler, url: "www.jjmhw.cc", features: { nsfw: true } }; //#endregion export { route };