There is no extension that currently does this, and it's probably not possible via CSS either (since some interaction is required).
Invidious has an embed URL along with an API that everyone can use, so I'd say that this is definitely possible either via a custom extender or an extension.
Example: https://invidious.snopyta.org/embed/dQw4w9WgXcQ
If an extension existed, it should have these features:
- Ability to choose an instance URL, or to choose automatic instance that is currently online (there's an API for this)
- Take into account that not all instances are always online
- Show embed either through BBCode or a raw link pasted in the post
It shouldn't be too hard for someone to create such extension (could just reuse code from FoF Formatting?). Maybe this could be turned into a proposal as well?
Edit:
A very simple and very dirty solution with pure JS:
<script type="text/javascript">
instance_url = "https://invidious.snopyta.org";
window.onload = () => {
embeds = document.querySelectorAll(`.DiscussionPage-stream .PostStream-item .Post-body a[href^="${instance_url}/embed/"]`);
for (let i = 0; i < embeds.length; i++) {
embed_url = embeds[i].attributes['href'].value;
embeds[i].outerHTML = `<iframe src="${embed_url}" width="560" height="315" title="Invidious video player" frameborder="0" allowfullscreen></iframe>`;
}
};
</script>
Paste in Admin > Appearance > Custom footer. Format: [](https://invidious.snopyta.org/embed/dQw4w9WgXcQ)
(paste in post). Can set the instance_url
variable to use your own instance (must include the protocol, in this case https://
)
This is just an example of how it could look. It's not a serious solution, as it doesn't take into account the SPA nature of Flarum (thus, the embed will load only on page reload, not when navigating through posts or discussions).
Example: