Merge branch 'dev'

This commit is contained in:
ccbikai
2024-08-07 21:58:52 +08:00

View File

@@ -83,6 +83,19 @@ function getLinkPreview($, item, { staticProxy, index }) {
return $.html(link)
}
function getReply($, item, { channel }) {
const reply = $(item).find('.tgme_widget_message_reply')
reply?.wrapInner('<small></small>')?.wrapInner('<blockquote></blockquote>')
const href = reply?.attr('href')
if (href) {
const url = new URL(href)
reply?.attr('href', `${url.pathname}`.replace(channel, 'posts'))
}
return $.html(reply)
}
function modifyHTMLContent($, content, { index } = {}) {
$(content).find('.emoji')?.attr('style', '')
$(content).find('a')?.each((_index, a) => {
@@ -99,7 +112,9 @@ function modifyHTMLContent($, content, { index } = {}) {
function getPost($, item, { channel, staticProxy, index = 0 }) {
item = item ? $(item).find('.tgme_widget_message') : $('.tgme_widget_message')
const content = modifyHTMLContent($, $(item).find('.tgme_widget_message_text'), { index })
const content = $(item).find('.js-message_reply_text')?.length > 0
? modifyHTMLContent($, $(item).find('.tgme_widget_message_text.js-message_text'), { index })
: modifyHTMLContent($, $(item).find('.tgme_widget_message_text'), { index })
const title = content?.text()?.match(/[^。\n]*(?=[。\n]|http)/g)?.[0] ?? content?.text() ?? ''
const id = $(item).attr('data-post')?.replace(`${channel}/`, '')
@@ -115,7 +130,7 @@ function getPost($, item, { channel, staticProxy, index = 0 }) {
tags,
text: content?.text(),
content: [
$.html($(item).find('.tgme_widget_message_reply')?.wrapInner('<small></small>')?.wrapInner('<blockquote></blockquote>')),
getReply($, item, { channel }),
getImages($, item, { staticProxy, id, index, title }),
getVideo($, item, { staticProxy, id, index, title }),
getAudio($, item, { staticProxy, id, index, title }),