Improve Twitter/X link handling and text formatting

- Use FxTwitter API for full note tweet text (with syndication API fallback)
- Save Twitter posts based on media content:
  - Videos → embed type (proxied video)
  - Images → image type (gallery)
  - Text-only → quote type
- Add granular preview badges: 'X VIDEO', 'X GALLERY', 'X POST'
- Preserve formatting/spacing with white-space: pre-wrap for quotes and descriptions
- Rename VideoInfo to EmbedInfo for better semantic clarity
This commit is contained in:
soup 2026-01-18 00:03:30 -05:00
parent 8a046728ef
commit 4a2cb341fa
Signed by: soup
SSH key fingerprint: SHA256:GYxje8eQkJ6HZKzVWDdyOUF1TyDiprruGhE0Ym8qYDY
7 changed files with 249 additions and 137 deletions

View file

@ -183,7 +183,17 @@ async function fetchPreview(url) {
html += `<div class="preview-description">${escapeHtml(data.description)}</div>`;
}
if (data.isEmbed) {
html += `<div class="preview-badge">${escapeHtml(data.provider.toUpperCase())} VIDEO</div>`;
let badge = data.provider.toUpperCase() + ' VIDEO';
if (data.provider === 'twitter') {
if (data.mediaType === 'video') {
badge = 'X VIDEO';
} else if (data.mediaType === 'images') {
badge = 'X GALLERY';
} else {
badge = 'X POST';
}
}
html += `<div class="preview-badge">${escapeHtml(badge)}</div>`;
}
preview.innerHTML = html || "<div>No preview available</div>";