Add tweet embed and oEmbed API support

This commit is contained in:
Zed 2026-07-18 12:46:43 +02:00
commit 9be0b8f826
10 changed files with 389 additions and 31 deletions

26
public/js/embedResize.js Normal file
View file

@ -0,0 +1,26 @@
(function() {
var embedElement = document.querySelector('.tweet-embed, .embed-video');
if (!embedElement) return;
var lastHeight = 0;
function sendHeight() {
var currentHeight = embedElement.offsetHeight;
if (currentHeight !== lastHeight) {
lastHeight = currentHeight;
window.parent.postMessage(['resizeIframe', { h: currentHeight, url: location.href }], '*');
}
}
// Respond to height requests from parent via MessageChannel
window.addEventListener('message', function(event) {
if (event.source === window.parent && event.ports && event.ports[0]) {
event.ports[0].postMessage(embedElement.offsetHeight);
}
});
window.addEventListener('load', sendHeight);
new ResizeObserver(sendHeight).observe(embedElement);
return sendHeight;
})()