mirror of
https://github.com/zedeus/nitter
synced 2026-09-05 22:59:31 +00:00
Add tweet embed and oEmbed API support
This commit is contained in:
parent
06c52473ab
commit
9be0b8f826
10 changed files with 389 additions and 31 deletions
23
public/js/embedTweet.js
Normal file
23
public/js/embedTweet.js
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
// This runs after embedResize.js sets up the sendHeight function
|
||||
(function(sendHeight) {
|
||||
// Make images load eagerly so height updates correctly
|
||||
var lazyImages = document.querySelectorAll('img[loading="lazy"]');
|
||||
for (var i = 0; i < lazyImages.length; i++) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
// Open all links in new tab (we're in an iframe)
|
||||
var allLinks = document.querySelectorAll('a');
|
||||
for (var i = 0; i < allLinks.length; i++) {
|
||||
allLinks[i].target = '_blank';
|
||||
}
|
||||
})(arguments[0]);
|
||||
Loading…
Reference in a new issue