Skip to content

Commit

Permalink
feat: enhance UI and fix video handling
Browse files Browse the repository at this point in the history
- Hide video elements in widget for improved user experience
- Update header background for better contrast
- Prevent empty image containers from rendering
- Remove unsupported video player elements
- Add onclick attribute to links for enhanced functionality
- Include Yandex.ru in target whitelist for expanded compatibility
  • Loading branch information
ccbikai committed Aug 9, 2024
1 parent 4f9a403 commit 50fc741
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/assets/item.css
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@
display: block !important;
}

.tgme_widget_message_video_wrap {
display: none;
}

.tgme_widget_message_poll_options {
display: block;

Expand Down
1 change: 1 addition & 0 deletions src/components/header.astro
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ const staticProxy = getEnv(import.meta.env, Astro, 'STATIC_PROXY') ?? '/static/'
<style>
#site-intro {
color: var(--secondary-color);
background-color: var(--code-background-color);
word-break: break-word;

& :global(.emoji) {
Expand Down
5 changes: 3 additions & 2 deletions src/lib/telegram/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function getImages($, item, { staticProxy, id, index, title }) {
</button>
`
})?.get()
return `<div class="image-list-container ${images.length % 2 === 0 ? 'image-list-even' : 'image-list-odd'}">${images?.join('')}</div>`
return images.length ? `<div class="image-list-container ${images.length % 2 === 0 ? 'image-list-even' : 'image-list-odd'}">${images?.join('')}</div>` : ''
}

function getVideo($, item, { staticProxy, index }) {
Expand Down Expand Up @@ -100,7 +100,7 @@ function getReply($, item, { channel }) {
function modifyHTMLContent($, content, { index } = {}) {
$(content).find('.emoji')?.attr('style', '')
$(content).find('a')?.each((_index, a) => {
$(a)?.attr('title', $(a)?.text())
$(a)?.attr('title', $(a)?.text())?.attr('onclick', '')
})
$(content).find('tg-spoiler')?.each((_index, spoiler) => {
const id = `spoiler-${index}-${_index}`
Expand Down Expand Up @@ -141,6 +141,7 @@ function getPost($, item, { channel, staticProxy, index = 0 }) {
// $(item).find('.tgme_widget_message_sticker_wrap')?.html(),
$(item).find('.tgme_widget_message_poll')?.html(),
$.html($(item).find('.tgme_widget_message_document_wrap')),
$.html($(item).find('.tgme_widget_message_video_player.not_supported')),
$.html($(item).find('.tgme_widget_message_location_wrap')),
getLinkPreview($, item, { staticProxy, index }),
].filter(Boolean).join('').replace(/(url\(["'])((https?:)?\/\/)/g, (match, p1, p2, _p3) => {
Expand Down
1 change: 1 addition & 0 deletions src/pages/static/[...url].js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const targetWhitelist = [
'telegram.dog',
'cdn-telegram.org',
'telesco.pe',
'yandex.ru',
]

export const prerender = false
Expand Down

0 comments on commit 50fc741

Please sign in to comment.