mirror of
https://github.com/olegvodyanov/instalinks.git
synced 2025-12-20 07:57:04 +03:00
Compare commits
4 Commits
174668e85f
...
849d3edd84
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
849d3edd84 | ||
|
|
b732d0b6b9 | ||
|
|
b5339cb9f0 | ||
|
|
dd073f0f34 |
@ -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;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user