diff --git a/src/messages.js b/src/messages.js index b73221a..c7ad0a2 100644 --- a/src/messages.js +++ b/src/messages.js @@ -104,6 +104,16 @@ export class MessageManager { } } catch {} + // Check if content is a Giphy URL + if (decrypted.includes('giphy.com')) { + return { + type: 'media', + content: '', + mediaUrl: decrypted, + urls: [decrypted] + }; + } + // Then check for media links const mediaMatch = decrypted.match(/https?:\/\/[^\s<]+[^<.,:;"')\]\s](?:\.(?:jpg|jpeg|gif|png|mp4|webm|mov|ogg))/i); const urlMatch = decrypted.match(/https?:\/\/[^\s<]+/g); diff --git a/src/popup.js b/src/popup.js index 707931f..6105ab0 100644 --- a/src/popup.js +++ b/src/popup.js @@ -835,7 +835,7 @@ function renderGifs(gifs, container) { const item = document.createElement('div'); item.className = 'gif-item'; item.style.position = 'relative'; - item.style.paddingBottom = '75%'; // 4:3 aspect ratio + item.style.paddingBottom = '75%'; const img = document.createElement('img'); img.src = gif.previewUrl; @@ -849,6 +849,21 @@ function renderGifs(gifs, container) { img.style.objectFit = 'cover'; img.style.borderRadius = '8px'; + // Add click handler with cleaned URL + item.addEventListener('click', () => { + const messageInput = document.getElementById('messageInput'); + // Clean the URL by removing query parameters + const cleanUrl = gif.url.split('?')[0]; + messageInput.value = cleanUrl; + messageInput.focus(); + + // Remove the GIF picker + const picker = document.querySelector('.gif-picker'); + if (picker) { + picker.remove(); + } + }); + item.appendChild(img); container.appendChild(item); });