mirror of
https://github.com/zedeus/nitter
synced 2026-09-05 14:49:32 +00:00
Clean up embed JS and add Tweet.html compatibility
This commit is contained in:
parent
dc66bd6375
commit
3bfbb7b3fd
4 changed files with 13 additions and 10 deletions
|
|
@ -24,4 +24,4 @@
|
|||
|
||||
// Expose for embedTweet.js
|
||||
window._nitterSendHeight = sendHeight;
|
||||
})()
|
||||
})();
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
// This runs after embedResize.js sets up the sendHeight function
|
||||
(function() {
|
||||
var sendHeight = window._nitterSendHeight;
|
||||
if (!sendHeight) return;
|
||||
|
||||
// Make images load eagerly so height updates correctly
|
||||
var lazyImages = document.querySelectorAll('img[loading="lazy"]');
|
||||
|
|
@ -9,12 +8,14 @@
|
|||
lazyImages[i].loading = 'eager';
|
||||
}
|
||||
|
||||
// Update height when images finish loading
|
||||
var allImages = document.querySelectorAll('img');
|
||||
for (var i = 0; i < allImages.length; i++) {
|
||||
var img = allImages[i];
|
||||
if (!img.complete) {
|
||||
img.addEventListener('load', sendHeight);
|
||||
// Update height when images finish loading (only if sendHeight available)
|
||||
if (sendHeight) {
|
||||
var allImages = document.querySelectorAll('img');
|
||||
for (var i = 0; i < allImages.length; i++) {
|
||||
var img = allImages[i];
|
||||
if (!img.complete) {
|
||||
img.addEventListener('load', sendHeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -23,4 +24,5 @@
|
|||
for (var i = 0; i < allLinks.length; i++) {
|
||||
allLinks[i].target = '_blank';
|
||||
}
|
||||
|
||||
})();
|
||||
|
|
|
|||
Loading…
Reference in a new issue