From bab09f9c4e13625bec20311c80bfb8796f4e62fc Mon Sep 17 00:00:00 2001 From: Goren G Date: Sun, 17 Dec 2023 23:24:51 +0800 Subject: [PATCH] fix(route): sehuatang append images in `.pattl` (#14055) --- lib/v2/sehuatang/index.js | 22 ++++++++++------------ lib/v2/sehuatang/user.js | 23 +++++++++++------------ 2 files changed, 21 insertions(+), 24 deletions(-) diff --git a/lib/v2/sehuatang/index.js b/lib/v2/sehuatang/index.js index 8d9e9a90cb..b4b8db9081 100644 --- a/lib/v2/sehuatang/index.js +++ b/lib/v2/sehuatang/index.js @@ -88,20 +88,18 @@ module.exports = async (ctx) => { $(image).replaceWith($(``)); } } - // if postMessage does not have any images, try to parse image url from `.pattl` - if (images.length === 0) { - const pattl = $('.pattl'); - const pattlImages = $(pattl).find('img'); - for (const pattlImage of pattlImages) { - const file = $(pattlImage).attr('file'); - if (!file || file === 'undefined') { - $(pattlImage).replaceWith(''); - } else { - $(pattlImage).replaceWith($(``)); - } + // also parse image url from `.pattl` + const pattl = $('.pattl'); + const pattlImages = $(pattl).find('img'); + for (const pattlImage of pattlImages) { + const file = $(pattlImage).attr('file'); + if (!file || file === 'undefined') { + $(pattlImage).replaceWith(''); + } else { + $(pattlImage).replaceWith($(``)); } - postMessage.append($(pattl)); } + postMessage.append($(pattl)); $('em[onclick]').remove(); info.description = (postMessage.html() || '抓取原帖失败').replace(/ignore_js_op/g, 'div'); diff --git a/lib/v2/sehuatang/user.js b/lib/v2/sehuatang/user.js index 889ebcf17f..cf0fb40bcf 100644 --- a/lib/v2/sehuatang/user.js +++ b/lib/v2/sehuatang/user.js @@ -62,20 +62,19 @@ module.exports = async (ctx) => { $(image).replaceWith($(``)); } } - // if postMessage does not have any images, try to parse image url from `.pattl` - if (images.length === 0) { - const pattl = $('.pattl'); - const pattlImages = $(pattl).find('img'); - for (const pattlImage of pattlImages) { - const file = $(pattlImage).attr('file'); - if (!file || file === 'undefined') { - $(pattlImage).replaceWith(''); - } else { - $(pattlImage).replaceWith($(``)); - } + // also parse image url from `.pattl` + const pattl = $('.pattl'); + const pattlImages = $(pattl).find('img'); + for (const pattlImage of pattlImages) { + const file = $(pattlImage).attr('file'); + if (!file || file === 'undefined') { + $(pattlImage).replaceWith(''); + } else { + $(pattlImage).replaceWith($(``)); } - postMessage.append($(pattl)); } + postMessage.append($(pattl)); + $('em[onclick]').remove(); info.description = (postMessage.html() || '抓取原帖失败').replace(/ignore_js_op/g, 'div');