logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe git clone https://hacktivis.me/git/mastofe.git

embed.js (937B)


  1. (function() {
  2. 'use strict';
  3. var ready = function(loaded) {
  4. if (['interactive', 'complete'].indexOf(document.readyState) !== -1) {
  5. loaded();
  6. } else {
  7. document.addEventListener('DOMContentLoaded', loaded);
  8. }
  9. };
  10. ready(function() {
  11. var iframes = [];
  12. window.addEventListener('message', function(e) {
  13. var data = e.data || {};
  14. if (data.type !== 'setHeight' || !iframes[data.id]) {
  15. return;
  16. }
  17. iframes[data.id].height = data.height;
  18. });
  19. [].forEach.call(document.querySelectorAll('iframe.mastodon-embed'), function(iframe) {
  20. iframe.scrolling = 'no';
  21. iframe.style.overflow = 'hidden';
  22. iframes.push(iframe);
  23. var id = iframes.length - 1;
  24. iframe.onload = function() {
  25. iframe.contentWindow.postMessage({
  26. type: 'setHeight',
  27. id: id,
  28. }, '*');
  29. };
  30. iframe.onload();
  31. });
  32. });
  33. })();