Compare commits

...

4 Commits

Author SHA1 Message Date
Олег Водянов
849d3edd84
Merge pull request #24 from olegvodyanov/use_iframe
All checks were successful
continuous-integration/drone/push Build is passing
use_iframe
2025-04-23 13:37:46 +04:00
oleg.vodyanov91@gmail.com
b732d0b6b9 use_iframe
All checks were successful
continuous-integration/drone/push Build is passing
2025-04-23 13:37:23 +04:00
Олег Водянов
b5339cb9f0
Merge pull request #23 from olegvodyanov/use_iframe
use_iframe
2025-04-23 13:35:32 +04:00
oleg.vodyanov91@gmail.com
dd073f0f34 use_iframe
All checks were successful
continuous-integration/drone/push Build is passing
2025-04-23 13:31:09 +04:00

View File

@ -7,6 +7,12 @@ const PER_PAGE = 8;
let currentPage = 1; let currentPage = 1;
let linksData = []; let linksData = [];
function extractReelId(url) {
// Example: https://www.instagram.com/reel/ABC123xyz/
const match = url.match(/instagram\.com\/reel\/([a-zA-Z0-9_-]+)/);
return match ? match[1] : null;
}
function loadLinks() { function loadLinks() {
const cacheKey = `links_cache_page_${currentPage}_per_${PER_PAGE}`; const cacheKey = `links_cache_page_${currentPage}_per_${PER_PAGE}`;
const cached = localStorage.getItem(cacheKey); const cached = localStorage.getItem(cacheKey);
@ -93,16 +99,34 @@ function createLinkElement(link, isWatched) {
const wrapper = document.createElement('div'); const wrapper = document.createElement('div');
wrapper.className = 'mb-3'; wrapper.className = 'mb-3';
// Instagram embed blockquote const reelId = extractReelId(link.url);
const blockquote = document.createElement('blockquote'); if (!reelId) {
blockquote.className = 'instagram-media'; wrapper.innerText = 'Invalid Instagram Reel URL';
blockquote.setAttribute('data-instgrm-permalink', link.url); return wrapper;
blockquote.style.background = '#FFF'; }
// Clean iframe embed
const iframeWrapper = document.createElement('div');
iframeWrapper.style.width = '100%';
iframeWrapper.style.height = '400px';
iframeWrapper.style.overflow = 'hidden';
iframeWrapper.style.borderRadius = '10px';
const iframe = document.createElement('iframe');
iframe.src = `https://www.instagram.com/reel/${reelId}/embed`;
iframe.width = '100%';
iframe.height = '600'; // taller to allow for cropping
iframe.style.border = 'none';
iframe.allowFullscreen = true;
iframe.loading = 'lazy';
iframe.style.marginTop = '-100px'; // shift to crop comments/likes
iframeWrapper.appendChild(iframe);
wrapper.appendChild(iframeWrapper);
const btnGroup = document.createElement('div');
btnGroup.className = 'mt-2 d-flex gap-2';
const p = document.createElement('p');
p.innerText = 'Loading Instagram...';
blockquote.appendChild(p);
wrapper.appendChild(blockquote);
// Button to mark watched if it's not watched // Button to mark watched if it's not watched
if (!isWatched) { if (!isWatched) {
@ -110,7 +134,7 @@ function createLinkElement(link, isWatched) {
watchButton.className = 'btn btn-sm btn-secondary'; watchButton.className = 'btn btn-sm btn-secondary';
watchButton.innerText = 'Mark Watched'; watchButton.innerText = 'Mark Watched';
watchButton.onclick = () => markLinkWatched(link.id); watchButton.onclick = () => markLinkWatched(link.id);
wrapper.appendChild(watchButton); btnGroup.appendChild(watchButton);
} }
// Delete button // Delete button
@ -118,7 +142,9 @@ function createLinkElement(link, isWatched) {
deleteButton.innerText = 'Delete'; deleteButton.innerText = 'Delete';
deleteButton.className = 'btn btn-sm btn-danger'; deleteButton.className = 'btn btn-sm btn-danger';
deleteButton.onclick = () => deleteLink(link.id); deleteButton.onclick = () => deleteLink(link.id);
wrapper.appendChild(deleteButton); btnGroup.appendChild(deleteButton);
wrapper.appendChild(btnGroup);
return wrapper; return wrapper;
} }