This commit is contained in:
2026-07-13 05:46:08 +02:00
parent bc85891027
commit 6a8986b160
2 changed files with 27 additions and 9 deletions

View File

@@ -1932,6 +1932,8 @@ body.sidebar-right-hidden .global-sidebar-right {
padding: 5px; padding: 5px;
font-size: 0.9em; font-size: 0.9em;
border-bottom: 1px solid rgba(255, 255, 255, 0.05); border-bottom: 1px solid rgba(255, 255, 255, 0.05);
content-visibility: auto;
contain-intrinsic-size: 100px;
} }
.sidebar-activity .comment-content-inner { .sidebar-activity .comment-content-inner {

View File

@@ -489,8 +489,12 @@
}; };
const checkOverflow = () => { const checkOverflow = (targetElement) => {
document.querySelectorAll('.sidebar-activity .comment-content-inner').forEach(inner => { const targets = targetElement
? (targetElement.classList.contains('comment-content-inner') ? [targetElement] : targetElement.querySelectorAll('.comment-content-inner'))
: document.querySelectorAll('.sidebar-activity .comment-content-inner');
targets.forEach(inner => {
const container = inner.parentElement; const container = inner.parentElement;
const btn = container.querySelector('.read-more-btn'); const btn = container.querySelector('.read-more-btn');
if (!btn) return; if (!btn) return;
@@ -518,8 +522,14 @@
if (media.dataset.loadListenerBound) return; if (media.dataset.loadListenerBound) return;
media.dataset.loadListenerBound = 'true'; media.dataset.loadListenerBound = 'true';
media.addEventListener('load', checkOverflow, { once: true }); const inner = media.closest('.comment-content-inner');
media.addEventListener('loadedmetadata', checkOverflow, { once: true }); if (inner) {
media.addEventListener('load', () => checkOverflow(inner), { once: true });
media.addEventListener('loadedmetadata', () => checkOverflow(inner), { once: true });
} else {
media.addEventListener('load', () => checkOverflow(), { once: true });
media.addEventListener('loadedmetadata', () => checkOverflow(), { once: true });
}
}); });
}; };
@@ -531,7 +541,7 @@
const contentDiv = readBtn.closest('.comment-content'); const contentDiv = readBtn.closest('.comment-content');
if (contentDiv) { if (contentDiv) {
contentDiv.classList.toggle('expanded'); contentDiv.classList.toggle('expanded');
checkOverflow(); // Re-sync button text and visibility checkOverflow(contentDiv); // Re-sync button text and visibility for this element
} }
return; return;
} }
@@ -669,14 +679,20 @@
if (html) { if (html) {
const temp = document.createElement('div'); const temp = document.createElement('div');
temp.innerHTML = html; temp.innerHTML = html;
const addedNodes = [];
while (temp.firstElementChild) { while (temp.firstElementChild) {
container.appendChild(temp.firstElementChild); const node = temp.firstElementChild;
container.appendChild(node);
addedNodes.push(node);
} }
// Keep the IO sentinel at the very end so it triggers on the next scroll // Keep the IO sentinel at the very end so it triggers on the next scroll
if (ioSentinel) container.appendChild(ioSentinel); if (ioSentinel) container.appendChild(ioSentinel);
attachMediaLoadListeners(container);
checkOverflow(); addedNodes.forEach(node => {
fetchSidebarYoutubeTitles(container); attachMediaLoadListeners(node);
checkOverflow(node);
fetchSidebarYoutubeTitles(node);
});
// Auto-play converted GIF videos // Auto-play converted GIF videos
container.querySelectorAll('video.autoplay-gif').forEach(v => { v.autoplay = true; v.muted = true; v.play().catch(() => { v.addEventListener('canplay', () => v.play().catch(() => { }), { once: true }); }); }); container.querySelectorAll('video.autoplay-gif').forEach(v => { v.autoplay = true; v.muted = true; v.play().catch(() => { v.addEventListener('canplay', () => v.play().catch(() => { }), { once: true }); }); });
} }