this-fifo/jutsu

Override defaultLanguage in localStorage

qsdamar opened this issue · 2 comments

Hello and thank you for such a great library.

Since we are not able to override the Jitsi language once the language key set to localStorage, is there a way to manually inject a script to an iframe?

I'm trying to achieve something like this:

const script = `<script>localStorage.removeItem('language')</script>`;
const iframe = document.getElementsByTagName("iframe")[0];
iframe.contentWindow.document.head.appendChild(script);

The code written above is not working, it's just for example of what I'm thinking is possible. I would like to remove the language key on e.g. onMeetingEnd event, that way I'll be able to change language each time I start a new call.

Thanks in advance!

Hey @qsdamar thank you for the kind words!

Unfortunately what you are suggesting would be a major vulnerability if possible, <iframe> does not allow this sort of behaviour on cross-domains due to security policies (https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe#scripting) — I'm assuming you are using jitsi hosted with them

If you are self-hosting jitsi then you would be able to have the <iframe> under the same domain which would enable you to manipulate its DOM objects directly. Nevertheless, if you decide to self-host jitsi, I believe you would be better off looking at the defaults and server-side configuration of jitsi to change the language in there

I recommend you checkout their community for more information on how to setup this directly within a Jitsi instance you manage:
https://community.jitsi.org/t/how-to-force-a-certain-language-for-jitsi-meet-web-interface/51252

Hello @this-fifo, thank you for the quick answer.

Yes, we are using self-hosted Jitsi but the client app is a bit specific. I'm using React inside the Electron desktop app, and as far as I know, the Electron release build does not have a domain (where the localStorage is located), it basically uses file:// for the domain. Does that mean that we can not use the same domain even if we have self-hosted Jitsi?

I'm not sure if you are familiar with this approach, but any answer would be appreciated.