embedTweet.js 862 B

12345678910111213141516171819202122232425262728
  1. // This runs after embedResize.js sets up the sendHeight function
  2. (function() {
  3. var sendHeight = window._nitterSendHeight;
  4. // Make images load eagerly so height updates correctly
  5. var lazyImages = document.querySelectorAll('img[loading="lazy"]');
  6. for (var i = 0; i < lazyImages.length; i++) {
  7. lazyImages[i].loading = 'eager';
  8. }
  9. // Update height when images finish loading (only if sendHeight available)
  10. if (sendHeight) {
  11. var allImages = document.querySelectorAll('img');
  12. for (var i = 0; i < allImages.length; i++) {
  13. var img = allImages[i];
  14. if (!img.complete) {
  15. img.addEventListener('load', sendHeight);
  16. }
  17. }
  18. }
  19. // Open all links in new tab (we're in an iframe)
  20. var allLinks = document.querySelectorAll('a');
  21. for (var i = 0; i < allLinks.length; i++) {
  22. allLinks[i].target = '_blank';
  23. }
  24. })();