support stickers display

This commit is contained in:
某M氏
2024-08-05 20:14:44 +08:00
committed by GitHub
parent 2df9b66ed9
commit 086c00bd2c

View File

@@ -11,6 +11,32 @@ const cache = new LRUCache({
},
})
function getVideoStickers($, item, { staticProxy, index, title }) {
return $(item).find('.js-videosticker_video')?.map((_index, video) => {
const url = $(video).attr('src')
const imgurl = $(video).find('img').attr('src')
return `
<div style="background-image: none; width: 256px;">
<video src="${staticProxy + url}" width="100%" height="100%" alt="${title}" preload muted autoplay loop playsinline disablepictureinpicture >
<img src="${staticProxy + imgurl}" alt="${title}" loading="${index > 15 ? 'eager' : 'lazy'}" />
</video>
</div>
`
})?.get()?.join('')
}
function getImageStickers($, item, { staticProxy, index, title }) {
return $(item).find('.tgme_widget_message_sticker')?.map((_index, image) => {
// const bgurl = $(image).attr('style').match(/url\(["'](.*?)["']/)?.[1]
const url = $(image).attr('data-webp')
return `
<div class="image-preview-button image-preview-wrap">
<img src="${staticProxy + url}" style="width: 256px;" alt="${title}" loading="${index > 15 ? 'eager' : 'lazy'}" />
</div>
`
})?.get()?.join('')
}
function getImages($, item, { staticProxy, id, index, title }) {
return $(item).find('.tgme_widget_message_photo_wrap')?.map((_index, photo) => {
const url = $(photo).attr('style').match(/url\(["'](.*?)["']/)?.[1]
@@ -78,6 +104,8 @@ function getPost($, item, { channel, staticProxy, index = 0 }) {
text: content?.text(),
content: [
$.html($(item).find('.tgme_widget_message_reply')?.wrapInner('<small></small>')?.wrapInner('<blockquote></blockquote>')),
getImageStickers($, item, { staticProxy, index, title }),
getVideoStickers($, item, { staticProxy, index, title }),
getImages($, item, { staticProxy, id, index, title }),
getVideo($, item, { staticProxy, id, index, title }),
content?.html(),