Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
arbadacarbaYK authored Nov 23, 2024
1 parent 0f25109 commit 22d01b6
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
17 changes: 16 additions & 1 deletion src/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
});
Expand Down

0 comments on commit 22d01b6

Please sign in to comment.