style: auto format
This commit is contained in:
parent
873618e99d
commit
9f37d05ab6
|
|
@ -98,7 +98,11 @@ async function handler(ctx: Context): Promise<Data> {
|
|||
description:
|
||||
renderToString(
|
||||
<ThreeKnsDescription
|
||||
cover={$item.find('.entry-media img').attr('src')?.trim().replace('.', () => baseUrl)}
|
||||
cover={$item
|
||||
.find('.entry-media img')
|
||||
.attr('src')
|
||||
?.trim()
|
||||
.replace('.', () => baseUrl)}
|
||||
title={title}
|
||||
tid={$item.find('.jb-chakan').text().trim()}
|
||||
category={category}
|
||||
|
|
|
|||
|
|
@ -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'];
|
||||
|
|
|
|||
|
|
@ -346,21 +346,20 @@ async function handler(ctx) {
|
|||
const emoji = node.emoji;
|
||||
description = description.replaceAll(
|
||||
emoji.text,
|
||||
() => `<img alt="${emoji.text}" src="${emoji.icon_url}" style="margin: -1px 1px 0px; display: inline-block; width: 20px; height: 20px; vertical-align: text-bottom;" title="" referrerpolicy="no-referrer">`
|
||||
() =>
|
||||
`<img alt="${emoji.text}" src="${emoji.icon_url}" style="margin: -1px 1px 0px; display: inline-block; width: 20px; height: 20px; vertical-align: text-bottom;" title="" referrerpolicy="no-referrer">`
|
||||
);
|
||||
}
|
||||
// 处理转发带图评论的情况
|
||||
if (node?.pics?.length) {
|
||||
const { pics, text } = node;
|
||||
description = description.replaceAll(
|
||||
text,
|
||||
() =>
|
||||
pics
|
||||
.map(
|
||||
(pic) =>
|
||||
`<img alt="${text}" src="${pic.src}" style="margin: 0px 0px 0px; display: inline-block; width: ${pic.width}px; height: ${pic.height}px; vertical-align: text-bottom;" title="" referrerpolicy="no-referrer">`
|
||||
)
|
||||
.join('<br>')
|
||||
description = description.replaceAll(text, () =>
|
||||
pics
|
||||
.map(
|
||||
(pic) =>
|
||||
`<img alt="${text}" src="${pic.src}" style="margin: 0px 0px 0px; display: inline-block; width: ${pic.width}px; height: ${pic.height}px; vertical-align: text-bottom;" title="" referrerpolicy="no-referrer">`
|
||||
)
|
||||
.join('<br>')
|
||||
);
|
||||
}
|
||||
if (node?.type === 'RICH_TEXT_NODE_TYPE_TOPIC') {
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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'];
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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() || '');
|
||||
|
|
|
|||
|
|
@ -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)}` : ''}`;
|
||||
},
|
||||
|
|
|
|||
|
|
@ -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'];
|
||||
|
|
|
|||
|
|
@ -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'];
|
||||
|
|
|
|||
|
|
@ -146,10 +146,10 @@ const parseBlock = (block: Block, entityMap: Readonly<Record<string, Entity>>):
|
|||
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({
|
||||
|
|
|
|||
|
|
@ -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()),
|
||||
};
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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'),
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -143,15 +143,17 @@ export const handler = async (ctx: Context): Promise<Data> => {
|
|||
|
||||
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;
|
||||
|
|
|
|||
|
|
@ -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'];
|
||||
|
|
|
|||
|
|
@ -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>(.+?)<\/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>(.+?)<\/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/',
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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',
|
||||
},
|
||||
|
|
|
|||
|
|
@ -99,7 +99,8 @@ export const twitterGot = async (
|
|||
});
|
||||
}
|
||||
let dispatchers:
|
||||
undefined | {
|
||||
| undefined
|
||||
| {
|
||||
jar: CookieJar;
|
||||
agent: CookieAgent | ProxyAgent;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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']}`);
|
||||
|
|
|
|||
|
|
@ -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]
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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) =>
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ describe('directory-import', () => {
|
|||
|
||||
afterEach(() => {
|
||||
if (!tempDir) {
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
fs.rmSync(tempDir, { recursive: true, force: true });
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ const rofetch = createFetch({ fetch: (...args: Parameters<typeof fetch>) => 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}`);
|
||||
|
|
|
|||
Loading…
Reference in New Issue