和 中无用的内容
- newsContent.find('p, span, strong').each(function () {
- const element = content(this);
+ newsContent.find('p, span, strong').each((_, el) => {
+ const element = content(el);
const text = element.text().trim();
// 删除没有有用文本的元素,防止空元素被保留
diff --git a/lib/routes/bupt/scss.ts b/lib/routes/bupt/scss.ts
index 3a87e867e..7db560446 100644
--- a/lib/routes/bupt/scss.ts
+++ b/lib/routes/bupt/scss.ts
@@ -73,8 +73,8 @@ async function handler() {
const content = load(detailResponse.data);
const newsContent = content('.v_news_content');
- newsContent.find('p, span, strong').each(function () {
- const element = content(this);
+ newsContent.find('p, span, strong').each((_, el) => {
+ const element = content(el);
const text = element.text().trim();
if (text === '') {
element.remove();
diff --git a/lib/routes/cbaigui/index.ts b/lib/routes/cbaigui/index.ts
index b440f86a2..9a3872640 100644
--- a/lib/routes/cbaigui/index.ts
+++ b/lib/routes/cbaigui/index.ts
@@ -44,13 +44,13 @@ async function handler(ctx) {
// To handle lazy-loaded images from external sites.
- content('figure').each(function () {
- const image = content(this).find('img');
+ content('figure').each((_, el) => {
+ const image = content(el).find('img');
const src = image.prop('data-actualsrc') ?? image.prop('data-original');
const width = image.prop('data-rawwidth');
const height = image.prop('data-rawheight');
- content(this).replaceWith(
+ content(el).replaceWith(
renderFigure({
src,
width,
@@ -61,13 +61,13 @@ async function handler(ctx) {
// To remove watermarks on images.
- content('p img').each(function () {
- const image = content(this);
+ content('p img').each((_, el) => {
+ const image = content(el);
const src = image.prop('src').split('!')[0];
const width = image.prop('width');
const height = image.prop('height');
- content(this).replaceWith(
+ content(el).replaceWith(
renderFigure({
src,
width,
diff --git a/lib/routes/chinanews/index.ts b/lib/routes/chinanews/index.ts
index aaccff0ba..f8b1a3b83 100644
--- a/lib/routes/chinanews/index.ts
+++ b/lib/routes/chinanews/index.ts
@@ -61,9 +61,7 @@ async function handler(ctx) {
item.description = content('div.left_zw').html();
const info = content('div.left-t')
.contents()
- .filter(function () {
- return this.type === 'text';
- })
+ .filter((_, el) => el.type === 'text')
.text()
.split(' ');
item.pubDate = timezone(parseDate(info[0], 'YYYY年MM月DD日 HH:mm'), +8);
diff --git a/lib/routes/coomer/index.tsx b/lib/routes/coomer/index.tsx
index 4afffa1b4..cdd0cd8d4 100644
--- a/lib/routes/coomer/index.tsx
+++ b/lib/routes/coomer/index.tsx
@@ -87,9 +87,7 @@ async function handler(ctx) {
}
const filesHTML = renderSource(i);
let $ = load(filesHTML);
- const coomerFiles = $('img, a, audio, video').map(function () {
- return $(this).prop('outerHTML')!;
- });
+ const coomerFiles = $('img, a, audio, video').map((_, el) => $(el).prop('outerHTML')!);
let desc = '';
if (i.content) {
desc += ` ${$this.text()} ${$this.text()}`);
+ content('.file-player-image').each((_, el) => {
+ content(el).replaceWith(`
`);
});
item.description = content('article').html();
diff --git a/lib/routes/eastday/24.ts b/lib/routes/eastday/24.ts
index 6c50ffdab..43ed7a699 100644
--- a/lib/routes/eastday/24.ts
+++ b/lib/routes/eastday/24.ts
@@ -103,8 +103,8 @@ async function handler(ctx) {
});
const subContent = load(pageResponse.data);
- subContent('img').each(function () {
- subContent(this).attr('src', subContent(this).attr('data-url'));
+ subContent('img').each((_, el) => {
+ subContent(el).attr('src', subContent(el).attr('data-url'));
});
item.description += subContent('#J-contain_detail_cnt').html();
diff --git a/lib/routes/ecust/jwc/notice.ts b/lib/routes/ecust/jwc/notice.ts
index 8aecda512..056a09284 100644
--- a/lib/routes/ecust/jwc/notice.ts
+++ b/lib/routes/ecust/jwc/notice.ts
@@ -67,12 +67,13 @@ async function handler(ctx) {
const { data: response } = await got(item.link);
const content = load(response);
// remove all attrs and empty objects
- content('div.wp_articlecontent *').each(function () {
- if (!content(this).text().trim()) {
- return content(this).remove();
+ content('div.wp_articlecontent *').each((_, el) => {
+ if (!content(el).text().trim()) {
+ content(el).remove();
+ return;
}
- for (const attr in this.attribs) {
- content(this).removeAttr(attr);
+ for (const attr in el.attribs) {
+ content(el).removeAttr(attr);
}
});
const description = content('div.wp_articlecontent').first().html();
diff --git a/lib/routes/flyert/utils.ts b/lib/routes/flyert/utils.ts
index 78874f26b..5dbb268c5 100644
--- a/lib/routes/flyert/utils.ts
+++ b/lib/routes/flyert/utils.ts
@@ -26,11 +26,11 @@ async function loadContent(link) {
const firstpost = $('.firstpost');
// 修改图片中的链接
- firstpost.find('ignore_js_op img').each(function () {
- $(this).attr('src', $(this).attr('file'));
+ firstpost.find('ignore_js_op img').each((_, el) => {
+ $(el).attr('src', $(el).attr('file'));
// 移除无用属性
for (const attr of ['id', 'aid', 'zoomfile', 'file', 'zoomfile', 'class', 'onclick', 'title', 'inpost', 'alt', 'onmouseover']) {
- $(this).removeAttr(attr);
+ $(el).removeAttr(attr);
}
});
diff --git a/lib/routes/focustaiwan/index.tsx b/lib/routes/focustaiwan/index.tsx
index da8b52e5a..3c10cd06e 100644
--- a/lib/routes/focustaiwan/index.tsx
+++ b/lib/routes/focustaiwan/index.tsx
@@ -67,8 +67,8 @@ async function handler(ctx) {
const content = load(detailResponse.data);
- content('img').each(function () {
- content(this).html(`
`);
+ content('img').each((_, el) => {
+ content(el).html(`
`);
});
const image = content('meta[property="og:image"]').attr('content');
diff --git a/lib/routes/futunn/main.ts b/lib/routes/futunn/main.ts
index 92e3ddc0f..7ae650257 100644
--- a/lib/routes/futunn/main.ts
+++ b/lib/routes/futunn/main.ts
@@ -60,8 +60,8 @@ async function handler(ctx) {
const content = load(detailResponse.data);
content('.futu-news-time-stamp').remove();
- content('.nnstock').each(function () {
- content(this).replaceWith(`${content(this).text().replaceAll('$', '')}`);
+ content('.nnstock').each((_, el) => {
+ content(el).replaceWith(`${content(el).text().replaceAll('$', '')}`);
});
item.description = content('.origin_content').html();
diff --git a/lib/routes/futunn/topic.ts b/lib/routes/futunn/topic.ts
index 6451c34a5..3430771d6 100644
--- a/lib/routes/futunn/topic.ts
+++ b/lib/routes/futunn/topic.ts
@@ -86,8 +86,8 @@ async function handler(ctx) {
const content = load(detailResponse.data);
content('.futu-news-time-stamp').remove();
- content('.nnstock').each(function () {
- content(this).replaceWith(`${content(this).text().replaceAll('$', '')}`);
+ content('.nnstock').each((_, el) => {
+ content(el).replaceWith(`${content(el).text().replaceAll('$', '')}`);
});
item.description = content('.origin_content').html();
diff --git a/lib/routes/gamersecret/index.ts b/lib/routes/gamersecret/index.ts
index 6e6cbab45..4f91c1a47 100644
--- a/lib/routes/gamersecret/index.ts
+++ b/lib/routes/gamersecret/index.ts
@@ -86,8 +86,8 @@ async function handler(ctx) {
const content = load(detailResponse.data);
- content('img').each(function () {
- content(this).attr('src', content(this).attr('data-src'));
+ content('img').each((_, el) => {
+ content(el).attr('src', content(el).attr('data-src'));
});
item.author = content('.jeg_meta_author').text().replace(/by/, '');
diff --git a/lib/routes/gdut/oa-news.ts b/lib/routes/gdut/oa-news.ts
index a190200fa..7b1159869 100644
--- a/lib/routes/gdut/oa-news.ts
+++ b/lib/routes/gdut/oa-news.ts
@@ -131,19 +131,15 @@ async function handler(ctx) {
const node = $('#content');
// 清理样式
node.find('*')
- .filter(function () {
- return this.type === 'comment' || this.tagName === 'meta' || this.tagName === 'style';
- })
+ .filter((_, el) => el.type === 'comment' || el.tagName === 'meta' || el.tagName === 'style')
.remove();
node.find('*')
.contents()
- .filter(function () {
- return this.type === 'comment' || this.tagName === 'meta' || this.tagName === 'style';
- })
+ .filter((_, el) => el.type === 'comment' || el.tagName === 'meta' || el.tagName === 'style')
.remove();
- node.find('*').each(function () {
- if (this.attribs.style !== undefined) {
- const newSty = this.attribs.style
+ node.find('*').each((_, el) => {
+ if (el.attribs.style !== undefined) {
+ const newSty = el.attribs.style
.split(';')
.filter((s) => {
const styBlocklist = ['color:rgb(0,0,0)', 'color:black', 'background:rgb(255,255,255)', 'background:white', 'text-align:left', 'text-align:justify', 'font-style:normal', 'font-weight:normal'];
@@ -176,27 +172,27 @@ async function handler(ctx) {
})
.join(';');
if (newSty) {
- this.attribs.style = newSty;
+ el.attribs.style = newSty;
} else {
- delete this.attribs.style;
+ delete el.attribs.style;
}
}
- if (this.attribs.class && this.attribs.class.trim().startsWith('Mso')) {
- delete this.attribs.class;
+ if (el.attribs.class && el.attribs.class.trim().startsWith('Mso')) {
+ delete el.attribs.class;
}
- if (this.attribs.lang) {
- delete this.attribs.lang;
+ if (el.attribs.lang) {
+ delete el.attribs.lang;
}
- if (this.tagName === 'font' || this.tagName === 'o:p') {
- $(this).replaceWith(this.childNodes);
+ if (el.tagName === 'font' || el.tagName === 'o:p') {
+ $(el).replaceWith(el.childNodes);
}
- if (this.tagName === 'span' && !this.attribs.style) {
- $(this).replaceWith(this.childNodes);
+ if (el.tagName === 'span' && !el.attribs.style) {
+ $(el).replaceWith(el.childNodes);
}
});
- node.find('span').each(function () {
- if (this.childNodes.length === 0) {
- $(this).remove();
+ node.find('span').each((_, el) => {
+ if (el.childNodes.length === 0) {
+ $(el).remove();
}
});
diff --git a/lib/routes/getdr/index.ts b/lib/routes/getdr/index.ts
index 03e9c631a..296d65b62 100644
--- a/lib/routes/getdr/index.ts
+++ b/lib/routes/getdr/index.ts
@@ -45,8 +45,8 @@ async function handler() {
const content = load(detailResponse.data);
- content('.wp-block-image').each(function () {
- content(this).html(`
`);
+ content('.wp-block-image').each((_, el) => {
+ content(el).html(`
`);
});
item.description = content('div[data-widget_type="theme-post-content.default"]').html();
diff --git a/lib/routes/gxmzu/utils/index.ts b/lib/routes/gxmzu/utils/index.ts
index a12ee8949..44045ae3a 100644
--- a/lib/routes/gxmzu/utils/index.ts
+++ b/lib/routes/gxmzu/utils/index.ts
@@ -46,8 +46,8 @@ async function getNoticeList(ctx, url, host, titleSelector, dateSelector, conten
item.description = '该通知无法直接预览,请点击原文链接↑查看';
} else {
const $content = load($(contentSelector.content).html());
- $content('a').each(function () {
- const a = $(this);
+ $content('a').each((_, el) => {
+ const a = $(el);
const href = a.attr('href');
if (href && !href.startsWith('http')) {
a.attr('href', new URL(href, host).href);
diff --git a/lib/routes/hackernews/index.ts b/lib/routes/hackernews/index.ts
index dff606d2c..a2b9b2b71 100644
--- a/lib/routes/hackernews/index.ts
+++ b/lib/routes/hackernews/index.ts
@@ -105,14 +105,14 @@ async function handler(ctx) {
item.description = '';
- content('.comtr').each(function () {
- const author = content(this).find('.hnuser');
- const comment = content(this).find('.commtext');
+ content('.comtr').each((_, el) => {
+ const author = content(el).find('.hnuser');
+ const comment = content(el).find('.commtext');
item.description +=
`
`);
+ content('.hupu-img').each((_, el) => {
+ const imgSrc = content(el).attr('data-gif') || content(el).attr('data-origin') || content(el).attr('src');
+ content(el).parent().html(`
`);
});
// 分别获取内容元素
diff --git a/lib/routes/imagemagick/changelog.ts b/lib/routes/imagemagick/changelog.ts
index b02047493..1f8b3da89 100644
--- a/lib/routes/imagemagick/changelog.ts
+++ b/lib/routes/imagemagick/changelog.ts
@@ -54,8 +54,8 @@ async function handler() {
const title = item.text();
let description = '';
- item.nextUntil('h2').each(function () {
- description += $(this).html();
+ item.nextUntil('h2').each((_, el) => {
+ description += $(el).html();
});
return {
diff --git a/lib/routes/javdb/utils.ts b/lib/routes/javdb/utils.ts
index be78a271e..eaccdbef7 100644
--- a/lib/routes/javdb/utils.ts
+++ b/lib/routes/javdb/utils.ts
@@ -76,9 +76,9 @@ const ProcessItems = async (ctx, currentUrl, title) => {
content('#modal-review-watched, #modal-comment-warning, #modal-save-list').remove();
content('.review-buttons, .copy-to-clipboard, .preview-video-container, .play-button').remove();
- content('.preview-images img').each(function () {
- content(this).removeAttr('data-src');
- content(this).attr('src', content(this).parent().attr('href'));
+ content('.preview-images img').each((_, el) => {
+ content(el).removeAttr('data-src');
+ content(el).attr('src', content(el).parent().attr('href'));
});
item.category = content('.panel-block .value a')
diff --git a/lib/routes/javlibrary/utils.tsx b/lib/routes/javlibrary/utils.tsx
index e95f7ade6..6b0b10ff9 100644
--- a/lib/routes/javlibrary/utils.tsx
+++ b/lib/routes/javlibrary/utils.tsx
@@ -73,9 +73,9 @@ const ProcessItems = async (language, currentUrl, tryGet) => {
const content = load(detailResponse.data);
content('.icn_edit, .btn_videoplayer, a[rel="bookmark"]').remove();
- content('span').each(function () {
- if (content(this).attr('class')?.startsWith('icn_')) {
- content(this).remove();
+ content('span').each((_, el) => {
+ if (content(el).attr('class')?.startsWith('icn_')) {
+ content(el).remove();
}
});
diff --git a/lib/routes/jou/utils/index.ts b/lib/routes/jou/utils/index.ts
index 6e1a09759..0389671e7 100644
--- a/lib/routes/jou/utils/index.ts
+++ b/lib/routes/jou/utils/index.ts
@@ -48,8 +48,8 @@ async function getItems(ctx, url, host, tableClass, timeStyleClass1, titleStyleC
} else {
const contentHtml = $('.v_news_content').html();
const $content = load(contentHtml);
- $content('a').each(function () {
- const a = $(this);
+ $content('a').each((_, el) => {
+ const a = $(el);
const href = a.attr('href');
if (href && !href.startsWith('http')) {
a.attr('href', new URL(href, host).href);
diff --git a/lib/routes/kamen-rider-official/news.ts b/lib/routes/kamen-rider-official/news.ts
index 20ea40e73..79a7f7201 100644
--- a/lib/routes/kamen-rider-official/news.ts
+++ b/lib/routes/kamen-rider-official/news.ts
@@ -107,14 +107,14 @@ async function handler(ctx) {
const content = load(detailResponse);
- content('a.c-button').each(function () {
- content(this).parent().remove();
+ content('a.c-button').each((_, el) => {
+ content(el).parent().remove();
});
- content('img').each(function () {
- content(this).replaceWith(
+ content('img').each((_, el) => {
+ content(el).replaceWith(
renderDescription({
- src: content(this).prop('src'),
+ src: content(el).prop('src'),
})
);
});
diff --git a/lib/routes/kemono/index.tsx b/lib/routes/kemono/index.tsx
index 454e5d47a..8392e394f 100644
--- a/lib/routes/kemono/index.tsx
+++ b/lib/routes/kemono/index.tsx
@@ -170,8 +170,8 @@ function generateEnclosureInfo(htmlContent: string): { enclosure_url?: string; e
const $ = load(htmlContent);
let enclosureInfo = {};
- $('audio source, video source').each(function () {
- const src = $(this).attr('src');
+ $('audio source, video source').each((_, el) => {
+ const src = $(el).attr('src');
if (!src) {
return;
}
@@ -345,10 +345,10 @@ function processPosts(posts: KemonoPost[], authorName: string, limit: number) {
let replacementCount = 0;
const fanboxRegex = /downloads\.fanbox\.cc/;
- $('a').each(function () {
- const link = $(this).attr('href');
+ $('a').each((_, el) => {
+ const link = $(el).attr('href');
if (link && fanboxRegex.test(link)) {
- $(this).replaceWith(kemonoFileElements[replacementCount] || '');
+ $(el).replaceWith(kemonoFileElements[replacementCount] || '');
replacementCount++;
}
});
diff --git a/lib/routes/kisskiss/blog.ts b/lib/routes/kisskiss/blog.ts
index 83891a695..30cb72acc 100644
--- a/lib/routes/kisskiss/blog.ts
+++ b/lib/routes/kisskiss/blog.ts
@@ -58,9 +58,9 @@ async function handler(ctx) {
9
),
};
- body.find('a img').each(function () {
- $(this).attr('src', $(this).parent('a').attr('href'));
- $(this).unwrap();
+ body.find('a img').each((_, el) => {
+ $(el).attr('src', $(el).parent('a').attr('href'));
+ $(el).unwrap();
});
body.find('div.blog_data').remove();
i.description = `
`);
+ .html(`
`);
});
content('.inline-post').remove();
diff --git a/lib/routes/ngocn2/index.ts b/lib/routes/ngocn2/index.ts
index 7a1ea5819..69635ec4c 100644
--- a/lib/routes/ngocn2/index.ts
+++ b/lib/routes/ngocn2/index.ts
@@ -67,8 +67,8 @@ async function handler(ctx) {
const content = load(detailResponse.data);
- content('.gatsby-resp-image-link').each(function () {
- content(this).html(`
`);
+ content('.gatsby-resp-image-link').each((_, el) => {
+ content(el).html(`
`);
});
item.description = content('.article__content').html();
diff --git a/lib/routes/njxzc/lib.ts b/lib/routes/njxzc/lib.ts
index 632f580e8..e9d92d17b 100644
--- a/lib/routes/njxzc/lib.ts
+++ b/lib/routes/njxzc/lib.ts
@@ -71,15 +71,15 @@ async function handler() {
} else {
const $content = $('.wp_articlecontent');
// Convert wp_pdf_player iframes to download links
- $content.find('.wp_pdf_player').each(function () {
- const $iframe = $(this);
+ $content.find('.wp_pdf_player').each((_, el) => {
+ const $iframe = $(el);
const pdfSrc = $iframe.attr('pdfsrc') || '';
const pdfUrl = pdfSrc.startsWith('http') ? pdfSrc : new URL(pdfSrc, host).href;
$iframe.replaceWith(``);
});
// Fix relative URLs
- $content.find('a').each(function () {
- const $a = $(this);
+ $content.find('a').each((_, el) => {
+ const $a = $(el);
const href = $a.attr('href');
if (href && !href.startsWith('http')) {
$a.attr('href', new URL(href, host).href);
diff --git a/lib/routes/njxzc/utils/index.ts b/lib/routes/njxzc/utils/index.ts
index 761487a6e..7cfc716d9 100644
--- a/lib/routes/njxzc/utils/index.ts
+++ b/lib/routes/njxzc/utils/index.ts
@@ -36,15 +36,15 @@ async function getNoticeList(ctx, url, host, titleSelector, dateSelector, conten
} else {
const $content = $(contentSelector.content);
// Convert wp_pdf_player iframes to download links
- $content.find('.wp_pdf_player').each(function () {
- const $iframe = $(this);
+ $content.find('.wp_pdf_player').each((_, el) => {
+ const $iframe = $(el);
const pdfSrc = $iframe.attr('pdfsrc') || '';
const pdfUrl = pdfSrc.startsWith('http') ? pdfSrc : new URL(pdfSrc, host).href;
$iframe.replaceWith(``);
});
// Fix relative URLs
- $content.find('a').each(function () {
- const $a = $(this);
+ $content.find('a').each((_, el) => {
+ const $a = $(el);
const href = $a.attr('href');
if (href && !href.startsWith('http')) {
$a.attr('href', new URL(href, host).href);
diff --git a/lib/routes/nwnu/routes/lib/embed-resource.ts b/lib/routes/nwnu/routes/lib/embed-resource.ts
index de002b363..974738ca1 100644
--- a/lib/routes/nwnu/routes/lib/embed-resource.ts
+++ b/lib/routes/nwnu/routes/lib/embed-resource.ts
@@ -3,8 +3,8 @@ import { load } from 'cheerio';
export function processEmbedPDF(baseurl: string, html: string) {
const $ = load(html);
- $('div.wp_pdf_player').each(function () {
- const $div = $(this);
+ $('div.wp_pdf_player').each((_, el) => {
+ const $div = $(el);
const pdfsrc = $div.attr('pdfsrc') || '';
const downloadUrl = new URL(pdfsrc, baseurl).href;
const newDiv = ``;
diff --git a/lib/routes/nytimes/daily-briefing-chinese.tsx b/lib/routes/nytimes/daily-briefing-chinese.tsx
index cb0d28e8e..712b93166 100644
--- a/lib/routes/nytimes/daily-briefing-chinese.tsx
+++ b/lib/routes/nytimes/daily-briefing-chinese.tsx
@@ -70,8 +70,8 @@ async function handler() {
const images = detailResponse.data.match(/"url":"[^{}]+","name":"articleLarge"/g).map((e) => JSON.parse(`{${e}}`).url);
let i = 0;
- content('figure').each(function () {
- content(this).html(
+ content('figure').each((_, el) => {
+ content(el).html(
renderToString(
diff --git a/lib/routes/odaily/activity.ts b/lib/routes/odaily/activity.ts
index b414ba934..554b90bfa 100644
--- a/lib/routes/odaily/activity.ts
+++ b/lib/routes/odaily/activity.ts
@@ -56,10 +56,10 @@ async function handler(ctx) {
const content = load(detailResponse.data.match(/"content":"(.*)"}},"secondaryList":/)[1]);
- content('img').each(function () {
- content(this).attr(
+ content('img').each((_, el) => {
+ content(el).attr(
'src',
- content(this)
+ content(el)
.attr('src')
.replaceAll(String.raw`\"`, '')
);
diff --git a/lib/routes/odaily/user.ts b/lib/routes/odaily/user.ts
index b0ec1cf11..1a5e95b7d 100644
--- a/lib/routes/odaily/user.ts
+++ b/lib/routes/odaily/user.ts
@@ -60,10 +60,10 @@ async function handler(ctx) {
const content = load(detailResponse.data.match(/"content":"(.*)","extraction_tags":/)[1]);
- content('img').each(function () {
- content(this).attr(
+ content('img').each((_, el) => {
+ content(el).attr(
'src',
- content(this)
+ content(el)
.attr('src')
.replaceAll(String.raw`\"`, '')
);
diff --git a/lib/routes/onet/utils.ts b/lib/routes/onet/utils.ts
index d90710018..f43968e9c 100644
--- a/lib/routes/onet/utils.ts
+++ b/lib/routes/onet/utils.ts
@@ -18,9 +18,7 @@ const parseArticleContent = ($) => {
const content = $('[itemprop="articleBody"]');
$('*')
.contents()
- .filter(function () {
- return this.nodeType === 8;
- })
+ .filter((_, el) => el.nodeType === 8)
.remove();
content.find('aside').remove();
content.find('.videoPlayerContainer').remove();
diff --git a/lib/routes/oreno3d/get-sec-page-data.ts b/lib/routes/oreno3d/get-sec-page-data.ts
index a99feda25..4bc1f5daa 100644
--- a/lib/routes/oreno3d/get-sec-page-data.ts
+++ b/lib/routes/oreno3d/get-sec-page-data.ts
@@ -30,29 +30,29 @@ async function sync_detail(link) {
// 存为列表
$(sec_page_selector)
.find(author_selector)
- .each(function (i) {
- authors[i] = $(this).text();
+ .each((i, el) => {
+ authors[i] = $(el).text();
authors[i].replace(' ', ''); // 去空格
authors[i].trim(); // 去首尾空格
});
$(sec_page_selector)
.find(origins_selector)
- .each(function (i) {
- origins[i] = $(this).text();
+ .each((i, el) => {
+ origins[i] = $(el).text();
origins[i].replace(' ', '');
origins[i].trim();
});
$(sec_page_selector)
.find(characters_selector)
- .each(function (i) {
- characters[i] = $(this).text();
+ .each((i, el) => {
+ characters[i] = $(el).text();
characters[i].replace(' ', '');
characters[i].trim();
});
$(sec_page_selector)
.find(tags_selector)
- .each(function (i) {
- tags[i] = $(this).text();
+ .each((i, el) => {
+ tags[i] = $(el).text();
tags[i].replace(' ', '');
tags[i].trim();
});
diff --git a/lib/routes/qq88/index.ts b/lib/routes/qq88/index.ts
index d446c9bd2..31d75295b 100644
--- a/lib/routes/qq88/index.ts
+++ b/lib/routes/qq88/index.ts
@@ -67,8 +67,8 @@ async function handler(ctx) {
item.enclosure_url = links.eq(-1).attr('href');
item.description = `
`;
- links.each(function () {
- item.description += ``);
+ content('figure').each((_, el) => {
+ content(el).html(`
`);
});
item.description = content('.entry-content').html();
diff --git a/lib/routes/saraba1st/digest.tsx b/lib/routes/saraba1st/digest.tsx
index 027ba7405..4eac1717b 100644
--- a/lib/routes/saraba1st/digest.tsx
+++ b/lib/routes/saraba1st/digest.tsx
@@ -84,16 +84,16 @@ async function fetchContent(url) {
const stubS = subind('
`);
+ article.find('d-image').each((_, el) => {
+ $(el).replaceWith(`
`);
});
return {
diff --git a/lib/routes/sinchew/index.tsx b/lib/routes/sinchew/index.tsx
index e14e767cb..65873e01d 100644
--- a/lib/routes/sinchew/index.tsx
+++ b/lib/routes/sinchew/index.tsx
@@ -60,12 +60,12 @@ async function handler(ctx) {
content('.ads-frame, .read-more-msg').remove();
- content('figure').each(function () {
- content(this).replaceWith(
+ content('figure').each((_, el) => {
+ content(el).replaceWith(
renderToString(
-
+
`);
+ content('picture').each((_, el) => {
+ content(el).html(`
`);
});
item.description = content('.si-detail__content').html();
diff --git a/lib/routes/telegram/channel.ts b/lib/routes/telegram/channel.ts
index 10d433fba..878dabd69 100644
--- a/lib/routes/telegram/channel.ts
+++ b/lib/routes/telegram/channel.ts
@@ -658,13 +658,13 @@ async function handler(ctx) {
if (msgTypes.includes(UNSUPPORTED)) {
if (unsupportedNodes.length) {
unsupportedHtml += '
';
- unsupportedNodes.find('.message_media_not_supported_label').each(function () {
- const $this = $(this);
+ unsupportedNodes.find('.message_media_not_supported_label').each((_, el) => {
+ const $this = $(el);
unsupportedTitle += $this.text();
unsupportedHtml += `
';
diff --git a/lib/routes/thenewslens/index.ts b/lib/routes/thenewslens/index.ts
index c8d393002..e4b3c71d0 100644
--- a/lib/routes/thenewslens/index.ts
+++ b/lib/routes/thenewslens/index.ts
@@ -59,10 +59,10 @@ async function handler(ctx) {
content('a[data-sk="tooltip_parent"]').parent().remove();
content('.ad-section, .recommender-title, .navigation-content').remove();
- content('.article-img-container').each(function () {
- content(this).replaceWith(
+ content('.article-img-container').each((_, el) => {
+ content(el).replaceWith(
renderDescription({
- image: content(this).find('img')?.attr('data-srcset').split('?')[0] ?? undefined,
+ image: content(el).find('img')?.attr('data-srcset').split('?')[0] ?? undefined,
})
);
});
diff --git a/lib/routes/wechat/announce.ts b/lib/routes/wechat/announce.ts
index 37b124dae..c1cbc2c66 100644
--- a/lib/routes/wechat/announce.ts
+++ b/lib/routes/wechat/announce.ts
@@ -37,8 +37,8 @@ async function handler() {
const $ = load(htmlString);
const announceList = [];
- $('.mp_news_list > .mp_news_item').each(function () {
- const $item = $(this);
+ $('.mp_news_list > .mp_news_item').each((_, el) => {
+ const $item = $(el);
const $link = $item.find('a');
const time = $item.find('.read_more').text();
const title = $item.find('strong').text();
diff --git a/lib/routes/wenku8/chapter.ts b/lib/routes/wenku8/chapter.ts
index 7e1046de2..980b33a69 100644
--- a/lib/routes/wenku8/chapter.ts
+++ b/lib/routes/wenku8/chapter.ts
@@ -40,10 +40,10 @@ async function handler(ctx) {
const chapter_item = [];
- $('.ccss>a').each(function () {
+ $('.ccss>a').each((_, el) => {
chapter_item.push({
- title: $(this).text(),
- link: `https://www.wenku8.net/novel/${index}/${id}/` + $(this).attr('href'),
+ title: $(el).text(),
+ link: `https://www.wenku8.net/novel/${index}/${id}/` + $(el).attr('href'),
});
});
diff --git a/lib/routes/whu/util.ts b/lib/routes/whu/util.ts
index 12e5ca908..a95d883c2 100644
--- a/lib/routes/whu/util.ts
+++ b/lib/routes/whu/util.ts
@@ -48,9 +48,9 @@ const getItemDetail = async (item, rootUrl) => {
// Missing the `src` properties for the images.
// The `src` property should be replaced with the value of `orisrc` to show the image.
// Replace images in the content with custom JSX template.
- content('p.vsbcontent_img').each(function () {
- const image = content(this).find('img');
- content(this).replaceWith(
+ content('p.vsbcontent_img').each((_, el) => {
+ const image = content(el).find('img');
+ content(el).replaceWith(
renderDescription({
image: {
src: new URL(image.prop('orisrc'), rootUrl).href,
@@ -63,8 +63,8 @@ const getItemDetail = async (item, rootUrl) => {
// Missing the `src` properties for the videos.
// The `src` property should be replaced with the value of `vurl` to play the video.
// Replace videos in the content with custom JSX template.
- content('script[name="_videourl"]').each(function () {
- const video = content(this);
+ content('script[name="_videourl"]').each((_, el) => {
+ const video = content(el);
video.replaceWith(
renderDescription({
video: {
diff --git a/lib/routes/wsj/utils.tsx b/lib/routes/wsj/utils.tsx
index 109c3a785..4cba5ccac 100644
--- a/lib/routes/wsj/utils.tsx
+++ b/lib/routes/wsj/utils.tsx
@@ -42,8 +42,8 @@ const parseArticle = (item) =>
article.find('.bylineWrap').each((i, e) => {
$(e)
.find('p')
- .each(function () {
- $(this).replaceWith($(this).html());
+ .each((_, el) => {
+ $(el).replaceWith($(el).html());
});
});
diff --git a/lib/routes/wzu/news.ts b/lib/routes/wzu/news.ts
index 2f2ffe7d7..e73e22618 100644
--- a/lib/routes/wzu/news.ts
+++ b/lib/routes/wzu/news.ts
@@ -39,10 +39,10 @@ async function loadContent(link) {
// 图片相对链接处理
$('img').attr('src', (n, v) => new URL(v, baseUrl).href);
// 视频相对链接处理,替换原有播放方法 showVsbVideo
- $('.vsbcontent_video').each(function () {
- const u1 = $(this).find('script').attr('vurl');
+ $('.vsbcontent_video').each((_, el) => {
+ const u1 = $(el).find('script').attr('vurl');
videoUrl = new URL(u1, baseUrl).href;
- return $(this)
+ $(el)
.html('')
.html();
});
diff --git a/lib/routes/xjtu/dean.ts b/lib/routes/xjtu/dean.ts
index 922259252..d3d43b867 100644
--- a/lib/routes/xjtu/dean.ts
+++ b/lib/routes/xjtu/dean.ts
@@ -16,8 +16,8 @@ const parseContent = (htmlString) => {
.map((element) => $(element).text().trim());
const content = $('[id^="vsb_content"]');
- $('form > div > ul a').each(function () {
- $(this).appendTo(content);
+ $('form > div > ul a').each((_, el) => {
+ $(el).appendTo(content);
$('
').appendTo(content);
});
diff --git a/lib/routes/xjtu/ee-jzxx.ts b/lib/routes/xjtu/ee-jzxx.ts
index 8d8086a3b..d1103320b 100644
--- a/lib/routes/xjtu/ee-jzxx.ts
+++ b/lib/routes/xjtu/ee-jzxx.ts
@@ -76,8 +76,8 @@ async function handler(ctx) {
const description = content('div.art-body.wow.fadeInUp')
.clone() // 创建副本防止修改原始内容
.find('ul li') // 定位到附件列表项
- .each(function () {
- const $li = $(this);
+ .each((_, el) => {
+ const $li = $(el);
const newText = $li.html()?.replaceAll(/已下载[\s\S]*?<\/span>次/g, '') ?? '';
$li.html(newText.replace(/<\/a>\s*$/, ''));
})
diff --git a/lib/routes/xmnn/epaper.ts b/lib/routes/xmnn/epaper.ts
index 3ce7c1dbe..ceec1c717 100644
--- a/lib/routes/xmnn/epaper.ts
+++ b/lib/routes/xmnn/epaper.ts
@@ -70,8 +70,8 @@ async function handler(ctx) {
$('#pdfsrc').remove();
$('.bigImg, .smallImg').remove();
- $('a img').each(function () {
- $(this).parent().remove();
+ $('a img').each((_, el) => {
+ $(el).parent().remove();
});
let items = $('.br1, .br2, .titss')
diff --git a/lib/routes/xyu/notices.ts b/lib/routes/xyu/notices.ts
index 02b3f0352..bc700b68c 100644
--- a/lib/routes/xyu/notices.ts
+++ b/lib/routes/xyu/notices.ts
@@ -88,8 +88,8 @@ async function handler() {
if (content) {
const $content = load(content);
- $content('a').each(function () {
- const a = $(this);
+ $content('a').each((_, el) => {
+ const a = $(el);
const href = a.attr('href');
if (href && !href.startsWith('http')) {
a.attr('href', new URL(href, baseUrl).href);
diff --git a/lib/routes/ycwb/index.tsx b/lib/routes/ycwb/index.tsx
index 283c17f13..7f8682620 100644
--- a/lib/routes/ycwb/index.tsx
+++ b/lib/routes/ycwb/index.tsx
@@ -82,17 +82,15 @@ async function handler(ctx) {
const $comments = content('.main_article')
.contents()
- .filter(function () {
- return this.nodeType === 8;
- });
- $comments.each(function () {
+ .filter((_, el) => el.nodeType === 8);
+ $comments.each((_, el) => {
// Remove useless comments
- if (/audioPlayer|audio-box/.test(this.data)) {
- this.data = '';
+ if (/audioPlayer|audio-box/.test(el.data)) {
+ el.data = '';
}
// Filter author from comments
- if (/author/.test(this.data)) {
- item.author = this.data.split('