embedTweet.js 819 B

1234567891011121314151617181920212223242526
  1. // This runs after embedResize.js sets up the sendHeight function
  2. (function() {
  3. var sendHeight = window._nitterSendHeight;
  4. if (!sendHeight) return;
  5. // Make images load eagerly so height updates correctly
  6. var lazyImages = document.querySelectorAll('img[loading="lazy"]');
  7. for (var i = 0; i < lazyImages.length; i++) {
  8. lazyImages[i].loading = 'eager';
  9. }
  10. // Update height when images finish loading
  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. // Open all links in new tab (we're in an iframe)
  19. var allLinks = document.querySelectorAll('a');
  20. for (var i = 0; i < allLinks.length; i++) {
  21. allLinks[i].target = '_blank';
  22. }
  23. })();