mirror of
https://activitypub.software/TransFem-org/Sharkey.git
synced 2024-12-15 17:35:44 +01:00
32 lines
784 B
JavaScript
32 lines
784 B
JavaScript
|
/*
|
||
|
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||
|
* SPDX-License-Identifier: MIT
|
||
|
*/
|
||
|
//@ts-check
|
||
|
(() => {
|
||
|
/** @type {NodeListOf<HTMLIFrameElement>} */
|
||
|
const els = document.querySelectorAll('iframe[data-misskey-embed-id]');
|
||
|
|
||
|
window.addEventListener('message', function (event) {
|
||
|
els.forEach((el) => {
|
||
|
if (event.source !== el.contentWindow) {
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
const id = el.dataset.misskeyEmbedId;
|
||
|
|
||
|
if (event.data.type === 'misskey:embed:ready') {
|
||
|
el.contentWindow?.postMessage({
|
||
|
type: 'misskey:embedParent:registerIframeId',
|
||
|
payload: {
|
||
|
iframeId: id,
|
||
|
}
|
||
|
}, '*');
|
||
|
}
|
||
|
if (event.data.type === 'misskey:embed:changeHeight' && event.data.iframeId === id) {
|
||
|
el.style.height = event.data.payload.height + 'px';
|
||
|
}
|
||
|
});
|
||
|
});
|
||
|
})();
|