diff --git a/lib/routes/3kns/index.tsx b/lib/routes/3kns/index.tsx index 2b3763ad7..eb3363bb8 100644 --- a/lib/routes/3kns/index.tsx +++ b/lib/routes/3kns/index.tsx @@ -98,7 +98,11 @@ async function handler(ctx: Context): Promise { description: renderToString( baseUrl)} + cover={$item + .find('.entry-media img') + .attr('src') + ?.trim() + .replace('.', () => baseUrl)} title={title} tid={$item.find('.jb-chakan').text().trim()} category={category} diff --git a/lib/routes/agefans/update.ts b/lib/routes/agefans/update.ts index 81f180b7f..612164014 100644 --- a/lib/routes/agefans/update.ts +++ b/lib/routes/agefans/update.ts @@ -58,7 +58,7 @@ async function handler() { content('img').each((_, ele) => { if (!ele.attribs['data-original']) { - return; + return; } ele.attribs.src = ele.attribs['data-original']; diff --git a/lib/routes/bilibili/dynamic.ts b/lib/routes/bilibili/dynamic.ts index e720d5875..9d236d551 100644 --- a/lib/routes/bilibili/dynamic.ts +++ b/lib/routes/bilibili/dynamic.ts @@ -346,21 +346,20 @@ async function handler(ctx) { const emoji = node.emoji; description = description.replaceAll( emoji.text, - () => `${emoji.text}` + () => + `${emoji.text}` ); } // 处理转发带图评论的情况 if (node?.pics?.length) { const { pics, text } = node; - description = description.replaceAll( - text, - () => - pics - .map( - (pic) => - `${text}` - ) - .join('
') + description = description.replaceAll(text, () => + pics + .map( + (pic) => + `${text}` + ) + .join('
') ); } if (node?.type === 'RICH_TEXT_NODE_TYPE_TOPIC') { diff --git a/lib/routes/cls/telegraph.tsx b/lib/routes/cls/telegraph.tsx index a371fdb82..743c0b4bb 100644 --- a/lib/routes/cls/telegraph.tsx +++ b/lib/routes/cls/telegraph.tsx @@ -57,7 +57,7 @@ export const route: Route = { url: 'cls.cn/telegraph', description: `| 看盘 | 公司 | 加红 | 提醒 | 基金 | 港美股 | | ----- | ------------ | ---- | ------ | ---- | ------ | -| watch | announcement | red | remind | fund | hk_us |`, +| watch | announcement | red | remind | fund | hk\\_us |`, }; async function handler(ctx: Context) { diff --git a/lib/routes/cw/utils.ts b/lib/routes/cw/utils.ts index 16b9dbc58..e9935dc07 100644 --- a/lib/routes/cw/utils.ts +++ b/lib/routes/cw/utils.ts @@ -105,7 +105,7 @@ const parseItems = (list, context, tryGet) => $('.article__head .breadcrumb, .article__head h1, .article__provideViews, .ad').remove(); $('img.lazyload').each((_, img) => { if (!img.attribs['data-src']) { - return; + return; } img.attribs.src = img.attribs['data-src']; diff --git a/lib/routes/ecnu/jwc.ts b/lib/routes/ecnu/jwc.ts index 5ecce471c..9b11ae342 100644 --- a/lib/routes/ecnu/jwc.ts +++ b/lib/routes/ecnu/jwc.ts @@ -43,7 +43,11 @@ export const route: Route = { try { const { data } = await got(item.link); const $ = load(data); - item.description = $('div.article')?.html()?.replaceAll('src="/', () => `src="${baseUrl}/`)?.replaceAll('href="/', () => `href="${baseUrl}/`)?.trim(); + item.description = $('div.article') + ?.html() + ?.replaceAll('src="/', () => `src="${baseUrl}/`) + ?.replaceAll('href="/', () => `href="${baseUrl}/`) + ?.trim(); return item; } catch { // intranet diff --git a/lib/routes/f95zone/utils.ts b/lib/routes/f95zone/utils.ts index b39e06ac4..b2bc99351 100644 --- a/lib/routes/f95zone/utils.ts +++ b/lib/routes/f95zone/utils.ts @@ -39,7 +39,7 @@ export const processContent = (html: string): string => { changed = false; $('*').each((_, el) => { if (!(el.type === 'tag' && !ALLOWED_TAGS.has(el.name))) { - return; + return; } $(el).replaceWith($(el).html() || ''); diff --git a/lib/routes/flyert/forum.ts b/lib/routes/flyert/forum.ts index 9a4a65e1a..12474b0e6 100644 --- a/lib/routes/flyert/forum.ts +++ b/lib/routes/flyert/forum.ts @@ -90,7 +90,11 @@ export const route: Route = { { source: ['www.flyert.com.cn/forum.php'], target: (_, url) => { - const params = url.searchParams.entries().toArray().map(([key, value]) => key + '=' + value).join('&'); + const params = url.searchParams + .entries() + .toArray() + .map(([key, value]) => key + '=' + value) + .join('&'); return `/forum${params ? `/${encodeURIComponent(params)}` : ''}`; }, diff --git a/lib/routes/gamme/category.ts b/lib/routes/gamme/category.ts index 6027b81bc..c49830f28 100644 --- a/lib/routes/gamme/category.ts +++ b/lib/routes/gamme/category.ts @@ -30,7 +30,7 @@ async function handler(ctx) { $('.entry img').each((_, img) => { if (!(img.attribs['data-original'] || img.attribs['data-src'])) { - return; + return; } img.attribs.src = img.attribs['data-original'] || img.attribs['data-src']; diff --git a/lib/routes/gamme/tag.ts b/lib/routes/gamme/tag.ts index 4c9c854ce..c968f90d0 100644 --- a/lib/routes/gamme/tag.ts +++ b/lib/routes/gamme/tag.ts @@ -43,7 +43,7 @@ async function handler(ctx) { $('.entry img').each((_, img) => { if (!(img.attribs['data-original'] || img.attribs['data-src'])) { - return; + return; } img.attribs.src = img.attribs['data-original'] || img.attribs['data-src']; diff --git a/lib/routes/gcores/parser.ts b/lib/routes/gcores/parser.ts index adc76affa..43e1501b2 100644 --- a/lib/routes/gcores/parser.ts +++ b/lib/routes/gcores/parser.ts @@ -146,10 +146,10 @@ const parseBlock = (block: Block, entityMap: Readonly>): styles: Style[]; entity: Entity | null; }> = Array.from(inlineStyleRanges, (range) => ({ - ...range, - styles: [STYLES[range.style]], - entity: null, - })); + ...range, + styles: [STYLES[range.style]], + entity: null, + })); for (const range of entityRanges) { combinedRanges.push({ diff --git a/lib/routes/gov/chongqing/gzw.ts b/lib/routes/gov/chongqing/gzw.ts index cb3cedd0e..4335a8599 100644 --- a/lib/routes/gov/chongqing/gzw.ts +++ b/lib/routes/gov/chongqing/gzw.ts @@ -47,7 +47,10 @@ async function handler(ctx) { return { title: a.text(), - link: new URL(a.prop('href').replace(/^\./, () => category), rootUrl).href, + link: new URL( + a.prop('href').replace(/^\./, () => category), + rootUrl + ).href, pubDate: parseDate(item.find('span').text()), }; }); diff --git a/lib/routes/hitwh/today.ts b/lib/routes/hitwh/today.ts index 92dc93e04..868a7f40e 100644 --- a/lib/routes/hitwh/today.ts +++ b/lib/routes/hitwh/today.ts @@ -54,7 +54,13 @@ async function handler() { try { const { data } = await got(item.link); const $ = load(data); - item.description = $('div.wp_articlecontent').html() && $('div.wp_articlecontent').html().replaceAll('src="/', () => `src="${baseUrl}/`).replaceAll('href="/', () => `href="${baseUrl}/`).trim(); + item.description = + $('div.wp_articlecontent').html() && + $('div.wp_articlecontent') + .html() + .replaceAll('src="/', () => `src="${baseUrl}/`) + .replaceAll('href="/', () => `href="${baseUrl}/`) + .trim(); return item; } catch { // intranet diff --git a/lib/routes/hostmonit/cloudflareyes.tsx b/lib/routes/hostmonit/cloudflareyes.tsx index 9258907eb..71a96b9fe 100644 --- a/lib/routes/hostmonit/cloudflareyes.tsx +++ b/lib/routes/hostmonit/cloudflareyes.tsx @@ -139,7 +139,9 @@ async function handler(ctx) { return { item: items, - title: $('title').text().replace(/- .*$/, () => `- ${title}`), + title: $('title') + .text() + .replace(/- .*$/, () => `- ${title}`), link: currentUrl, description: $('meta[name="description"]').prop('content'), language: $('html').prop('lang'), diff --git a/lib/routes/jpxgmn/utils.tsx b/lib/routes/jpxgmn/utils.tsx index 2cea0aed0..945ce228e 100644 --- a/lib/routes/jpxgmn/utils.tsx +++ b/lib/routes/jpxgmn/utils.tsx @@ -27,11 +27,14 @@ const getArticleDesc = async (articleUrl) => { } const images = getImages($content); const otherImages = await Promise.all( - Array.from({ length: pageCnt - 1 }).keys().toArray().map(async (pageIndex) => { - const pageUrl = articleUrl.replace('.html', () => `_${pageIndex + 1}.html`); - const pageResponse = await got(pageUrl); - return getImages(load(pageResponse.data)); - }) + Array.from({ length: pageCnt - 1 }) + .keys() + .toArray() + .map(async (pageIndex) => { + const pageUrl = articleUrl.replace('.html', () => `_${pageIndex + 1}.html`); + const pageResponse = await got(pageUrl); + return getImages(load(pageResponse.data)); + }) ); const allImages = [...images, ...otherImages.flat()]; return renderToString( diff --git a/lib/routes/liulinblog/index.ts b/lib/routes/liulinblog/index.ts index c3b94293d..440e6f2da 100644 --- a/lib/routes/liulinblog/index.ts +++ b/lib/routes/liulinblog/index.ts @@ -77,7 +77,11 @@ async function handler(ctx) { item.guid = `liulinblog-${content('article').first().prop('id')}`; item.pubDate = parseDate(content('span.meta-date time').first().prop('datetime')); item.comments = content('h3.comments-title').text() - ? Number(content('h3.comments-title').text().match(/\((\d+)\)/)) + ? Number( + content('h3.comments-title') + .text() + .match(/\((\d+)\)/) + ) : 0; return item; diff --git a/lib/routes/locals/feed.ts b/lib/routes/locals/feed.ts index 566166bb9..9d2998704 100644 --- a/lib/routes/locals/feed.ts +++ b/lib/routes/locals/feed.ts @@ -129,7 +129,14 @@ function getRequestHeaders(session: string) { } function extractAssetUrls(html: string) { - return [...new Set(html.matchAll(/\/_build\/assets\/[^"'\s>]+\.js/g).toArray().map((match) => match[0]))]; + return [ + ...new Set( + html + .matchAll(/\/_build\/assets\/[^"'\s>]+\.js/g) + .toArray() + .map((match) => match[0]) + ), + ]; } function extractFeedActionId(asset: string) { diff --git a/lib/routes/oshwhub/explore.ts b/lib/routes/oshwhub/explore.ts index 51242cff0..968833c20 100644 --- a/lib/routes/oshwhub/explore.ts +++ b/lib/routes/oshwhub/explore.ts @@ -143,15 +143,17 @@ export const handler = async (ctx: Context): Promise => { const categories: string[] = [...new Set([...(item.category ?? []), origin ?? undefined, ...tags, result.license].filter(Boolean) as string[])]; const authors: DataItem['author'] = new Map( - [result.owner, result.creator, ...result.members].map((author) => { - const item = { - name: author.nickname, - url: new URL(author.username, baseUrl).href, - avatar: author.avatar ? `https:${author.avatar}` : undefined, - }; - return [`${item.name}|${item.url}`, item]; - }) - ).values().toArray(); + [result.owner, result.creator, ...result.members].map((author) => { + const item = { + name: author.nickname, + url: new URL(author.username, baseUrl).href, + avatar: author.avatar ? `https:${author.avatar}` : undefined, + }; + return [`${item.name}|${item.url}`, item]; + }) + ) + .values() + .toArray(); const guid: string = result.uuid ? `oshwhub-${result.uuid}` : item.guid || ''; const image: string | undefined = result.thumb?.startsWith('https:') ? result.thumb : `https:${result.thumb}`; const upDatedStr: string | undefined = result.updated_at || pubDateStr; diff --git a/lib/routes/pikabu/utils.ts b/lib/routes/pikabu/utils.ts index 15fddbc5c..87a78b19b 100644 --- a/lib/routes/pikabu/utils.ts +++ b/lib/routes/pikabu/utils.ts @@ -6,7 +6,7 @@ const fixImage = (element) => { element.find('.story-image__stretch').remove(); element.find('.story-image__image').each((_, img) => { if (!(img.attribs['data-src'] && img.attribs['data-large-image'])) { - return; + return; } img.attribs.src = img.attribs['data-large-image']; diff --git a/lib/routes/sec-wiki/weekly.ts b/lib/routes/sec-wiki/weekly.ts index dcb5d132a..1f74f3b6a 100644 --- a/lib/routes/sec-wiki/weekly.ts +++ b/lib/routes/sec-wiki/weekly.ts @@ -22,11 +22,14 @@ export const route: Route = { async function handler() { const { data } = await got('https://www.sec-wiki.com/weekly/index'); - const items = data.matchAll(/\/weekly\/(\d+)">(.+?)<\/a><\/h5>\s*

(.+?)<\/p>/g).toArray().map((item) => ({ - title: item[2], - link: `https://www.sec-wiki.com/weekly/${item[1]}`, - description: item[3], - })); + const items = data + .matchAll(/\/weekly\/(\d+)">(.+?)<\/a><\/h5>\s*

(.+?)<\/p>/g) + .toArray() + .map((item) => ({ + title: item[2], + link: `https://www.sec-wiki.com/weekly/${item[1]}`, + description: item[3], + })); return { title: 'SecWiki-安全维基', link: 'https://www.sec-wiki.com/', diff --git a/lib/routes/taoguba/util.ts b/lib/routes/taoguba/util.ts index 90e5ea5a8..90f4e3070 100644 --- a/lib/routes/taoguba/util.ts +++ b/lib/routes/taoguba/util.ts @@ -19,7 +19,7 @@ const renderPostDetail = async (item) => content('#videoImg').remove(); content('img').each((_, img) => { if (!img.attribs.src2) { - return; + return; } img.attribs.src = img.attribs.src2; diff --git a/lib/routes/twitter/api/mobile-api/login.ts b/lib/routes/twitter/api/mobile-api/login.ts index da8af4281..47d8a79aa 100644 --- a/lib/routes/twitter/api/mobile-api/login.ts +++ b/lib/routes/twitter/api/mobile-api/login.ts @@ -57,27 +57,31 @@ const postTask = async (flowToken: string, subtaskId: string, subtaskInput: Reco // So abstract these tasks out into a map so that they can be dynamically executed during the login flow. // If there are missing tasks in the future, simply add the implementation of that task to it. const flowTasks = { - LoginEnterUserIdentifier: async ({ flowToken, username }) => await postTask(flowToken, 'LoginEnterUserIdentifier', { + LoginEnterUserIdentifier: async ({ flowToken, username }) => + await postTask(flowToken, 'LoginEnterUserIdentifier', { enter_text: { suggestion_id: null, text: username, link: 'next_link', }, }), - LoginEnterPassword: async ({ flowToken, password }) => await postTask(flowToken, 'LoginEnterPassword', { + LoginEnterPassword: async ({ flowToken, password }) => + await postTask(flowToken, 'LoginEnterPassword', { enter_password: { password, link: 'next_link', }, }), - LoginEnterAlternateIdentifierSubtask: async ({ flowToken, phoneOrEmail }) => await postTask(flowToken, 'LoginEnterAlternateIdentifierSubtask', { + LoginEnterAlternateIdentifierSubtask: async ({ flowToken, phoneOrEmail }) => + await postTask(flowToken, 'LoginEnterAlternateIdentifierSubtask', { enter_text: { suggestion_id: null, text: phoneOrEmail, link: 'next_link', }, }), - AccountDuplicationCheck: async ({ flowToken }) => await postTask(flowToken, 'AccountDuplicationCheck', { + AccountDuplicationCheck: async ({ flowToken }) => + await postTask(flowToken, 'AccountDuplicationCheck', { check_logged_in_account: { link: 'AccountDuplicationCheck_false', }, diff --git a/lib/routes/twitter/api/web-api/utils.ts b/lib/routes/twitter/api/web-api/utils.ts index 470fd4621..8d7624fb2 100644 --- a/lib/routes/twitter/api/web-api/utils.ts +++ b/lib/routes/twitter/api/web-api/utils.ts @@ -99,7 +99,8 @@ export const twitterGot = async ( }); } let dispatchers: - undefined | { + | undefined + | { jar: CookieJar; agent: CookieAgent | ProxyAgent; }; diff --git a/lib/routes/uchicago/current.ts b/lib/routes/uchicago/current.ts index c7fc2c69f..3912f2904 100644 --- a/lib/routes/uchicago/current.ts +++ b/lib/routes/uchicago/current.ts @@ -83,7 +83,7 @@ async function handler(ctx) { $('.figure__image').each((_, elem) => { if (!elem.attribs['data-lg-src']) { - return; + return; } $(elem).attr('src', `${baseUrl}${elem.attribs['data-lg-src']}`); diff --git a/lib/routes/wenku8/volume.ts b/lib/routes/wenku8/volume.ts index 97f209be9..4170309b4 100644 --- a/lib/routes/wenku8/volume.ts +++ b/lib/routes/wenku8/volume.ts @@ -42,7 +42,9 @@ async function handler(ctx) { title: `轻小说文库 ${$('#title').text()} 最新卷`, link, item: await cache.tryGet(volumeUrl, async () => - (await get(volumeUrl)).matchAll(/\s{2}(\S.*)\r?\n([\s\S]+?)\r?\n\r?\n/g).toArray() + (await get(volumeUrl)) + .matchAll(/\s{2}(\S.*)\r?\n([\s\S]+?)\r?\n\r?\n/g) + .toArray() .map((chapter, index) => ({ title: chapter[1], description: chapter[2] diff --git a/lib/routes/xaufe/jiaowu.ts b/lib/routes/xaufe/jiaowu.ts index 8addb2c16..2504fdd84 100644 --- a/lib/routes/xaufe/jiaowu.ts +++ b/lib/routes/xaufe/jiaowu.ts @@ -59,7 +59,10 @@ async function handler(ctx) { item = $(item); const pubDate = item.children('span').text(); const title = item.find('a em').text(); - const link = item.children('a').attr('href').replaceAll('../', () => rootMeta.url); + const link = item + .children('a') + .attr('href') + .replaceAll('../', () => rootMeta.url); return { pubDate: parseDate(pubDate), title, diff --git a/lib/routes/zhihu/collection.ts b/lib/routes/zhihu/collection.ts index e84b698c7..294b71a48 100644 --- a/lib/routes/zhihu/collection.ts +++ b/lib/routes/zhihu/collection.ts @@ -57,7 +57,11 @@ async function handler(ctx) { if (getAll) { const totals = response.data.paging.totals; - const offsetList = Array.from({ length: Math.round(totals / 20) }).keys().toArray().map((item) => item * 20).slice(1); + const offsetList = Array.from({ length: Math.round(totals / 20) }) + .keys() + .toArray() + .map((item) => item * 20) + .slice(1); const otherList = ( await Promise.all( offsetList.map((offset) => diff --git a/lib/utils/directory-import.test.ts b/lib/utils/directory-import.test.ts index 06a4fbab4..c8f30375a 100644 --- a/lib/utils/directory-import.test.ts +++ b/lib/utils/directory-import.test.ts @@ -18,7 +18,7 @@ describe('directory-import', () => { afterEach(() => { if (!tempDir) { - return; + return; } fs.rmSync(tempDir, { recursive: true, force: true }); diff --git a/lib/utils/ofetch.ts b/lib/utils/ofetch.ts index 619c51ede..359a73d4e 100644 --- a/lib/utils/ofetch.ts +++ b/lib/utils/ofetch.ts @@ -20,7 +20,7 @@ const rofetch = createFetch({ fetch: (...args: Parameters) => fetc // timeout: config.requestTimeout, onResponseError({ request, response, options }) { if (!options.retry) { - return; + return; } logger.warn(`Request ${request} with error ${response.status} remaining retry attempts: ${options.retry}`);