This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
2017-09-09 07:23:44 -07:00
|
|
|
(function() {
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
var ready = function(loaded) {
|
|
|
|
if (['interactive', 'complete'].indexOf(document.readyState) !== -1) {
|
|
|
|
loaded();
|
|
|
|
} else {
|
|
|
|
document.addEventListener('DOMContentLoaded', loaded);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
ready(function() {
|
|
|
|
var iframes = [];
|
|
|
|
|
|
|
|
window.addEventListener('message', function(e) {
|
|
|
|
var data = e.data || {};
|
|
|
|
|
2022-02-01 08:34:48 -08:00
|
|
|
if (data.type !== 'setHeight' || !iframes[data.id] || window.location.origin !== e.origin || data.id.toString() === '__proto__') {
|
2017-09-09 07:23:44 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
iframes[data.id].height = data.height;
|
|
|
|
});
|
|
|
|
|
|
|
|
[].forEach.call(document.querySelectorAll('iframe.mastodon-embed'), function(iframe) {
|
|
|
|
iframe.scrolling = 'no';
|
|
|
|
iframe.style.overflow = 'hidden';
|
|
|
|
|
|
|
|
iframes.push(iframe);
|
|
|
|
|
|
|
|
var id = iframes.length - 1;
|
|
|
|
|
|
|
|
iframe.onload = function() {
|
|
|
|
iframe.contentWindow.postMessage({
|
|
|
|
type: 'setHeight',
|
|
|
|
id: id,
|
|
|
|
}, '*');
|
|
|
|
};
|
|
|
|
|
|
|
|
iframe.onload();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
})();
|