diff --git a/lib/routes/cbaigui/utils.ts b/lib/routes/cbaigui/utils.ts index 713d0d676..eb43835f1 100644 --- a/lib/routes/cbaigui/utils.ts +++ b/lib/routes/cbaigui/utils.ts @@ -8,7 +8,7 @@ const GetFilterId = async (type, name) => { const { data: filterResponse } = await got(filterApiUrl); - return filterResponse.filter((f) => f.name === name).pop()?.id ?? undefined; + return filterResponse.findLast((f) => f.name === name)?.id ?? undefined; }; export { rootUrl, apiSlug, GetFilterId }; diff --git a/lib/routes/gov/zhengce/index.ts b/lib/routes/gov/zhengce/index.ts index a1e45ef7a..1c648fc54 100644 --- a/lib/routes/gov/zhengce/index.ts +++ b/lib/routes/gov/zhengce/index.ts @@ -70,19 +70,16 @@ async function handler(ctx) { const agencyEl = content('table.bd1') .find('td') .toArray() - .filter((a) => content(a).text().startsWith('发文机关')) - .pop(); + .findLast((a) => content(a).text().startsWith('发文机关')); const sourceEl = content('span.font-zyygwj') .toArray() - .filter((a) => content(a).text().startsWith('来源')) - .pop(); + .findLast((a) => content(a).text().startsWith('来源')); const subjectEl = content('table.bd1') .find('td') .toArray() - .filter((a) => content(a).text().startsWith('主题分类')) - .pop(); + .findLast((a) => content(a).text().startsWith('主题分类')); const agency = agencyEl ? processElementText(agencyEl) : undefined; const source = sourceEl ? processElementText(sourceEl) : undefined; diff --git a/lib/routes/line/today.ts b/lib/routes/line/today.ts index 0260748e9..da835e7fc 100644 --- a/lib/routes/line/today.ts +++ b/lib/routes/line/today.ts @@ -40,7 +40,7 @@ async function handler(ctx) { url: tabUrl, }); - const listing = moduleResponse.data.modules.filter((item) => item.source === 'CATEGORY_MOST_VIEW').pop().listings[0]; + const listing = moduleResponse.data.modules.findLast((item) => item.source === 'CATEGORY_MOST_VIEW').listings[0]; title = moduleResponse.data.name; moduleUrl = diff --git a/lib/routes/logclub/index.ts b/lib/routes/logclub/index.ts index 45b2d3669..0fa828af9 100644 --- a/lib/routes/logclub/index.ts +++ b/lib/routes/logclub/index.ts @@ -109,8 +109,7 @@ async function handler(ctx) { content( content('div.video_info_item, div.lc-infos div') .toArray() - .filter((i) => /\d{4}-\d{2}-\d{2}/.test(content(i).text())) - .pop() + .findLast((i) => /\d{4}-\d{2}-\d{2}/.test(content(i).text())) ) .text() .split(/:/) diff --git a/lib/routes/luolei/index.ts b/lib/routes/luolei/index.ts index d07ce12f6..872147245 100644 --- a/lib/routes/luolei/index.ts +++ b/lib/routes/luolei/index.ts @@ -39,8 +39,7 @@ export const handler = async (ctx) => { const language = $('html').prop('lang'); const themeEl = $('link[rel="modulepreload"]') .toArray() - .filter((l) => /theme\.\w+\.js$/.test($(l).prop('href'))) - .pop(); + .findLast((l) => /theme\.\w+\.js$/.test($(l).prop('href'))); const themeUrl = themeEl ? new URL($(themeEl).prop('href'), rootUrl).href : undefined; const { data: themeResponse } = await got(themeUrl); diff --git a/lib/routes/newzmz/util.ts b/lib/routes/newzmz/util.ts index 3d301187f..64ccce324 100644 --- a/lib/routes/newzmz/util.ts +++ b/lib/routes/newzmz/util.ts @@ -154,7 +154,7 @@ const processItems = async (i, downLinkType, itemSelector, categorySelector, dow author: i.author, category: [...i.category, ...categories].filter(Boolean), pubDate: i.pubDate, - enclosure_url: downLinks.filter((l) => l.title === downLinkType).pop()?.link ?? downLinks[0].link, + enclosure_url: downLinks.findLast((l) => l.title === downLinkType)?.link ?? downLinks[0].link, enclosure_type: 'application/x-bittorrent', }; }); diff --git a/lib/routes/tesla/cx.ts b/lib/routes/tesla/cx.ts index 63e1c83ad..b553e6513 100644 --- a/lib/routes/tesla/cx.ts +++ b/lib/routes/tesla/cx.ts @@ -127,7 +127,7 @@ async function handler(ctx) { }, }); - const categoryObject = categoryResponse.data.filter((c) => c.name === category).pop(); + const categoryObject = categoryResponse.data.findLast((c) => c.name === category); const { data: response } = await got(apiUrl, { searchParams: {