Search Support

Avoid support scams. We will never ask you to call or text a phone number or share personal information. Please report suspicious activity using the “Report Abuse” option.

Learn More

How to add own javascript code to a Mozilla Hubs room?

more options

Hi!

We are trying to use Mozilla Hubs in a customer case, but we need to add functionality (javascript logic that manages some objects) to the rooms. How can this be done? I've tried:

- ... to search for an injection point in the Hubs server running in AWS, but cannot find it (how the room web page is created and from which templates, and where the templates are?) - ... to deploy our custom Hubs server using "npm run deploy", but the server gets broken and cannot load rooms any more...

Ideally I'd just mod an existing server without deploying it again as the customer might not allow redeploying...

PS. We cannot create a browser plugin as the customer uses Oculus Quests to run Hubs, and on Quest you cannot use your own browser plugins...

Thanks!

Hi! We are trying to use Mozilla Hubs in a customer case, but we need to add functionality (javascript logic that manages some objects) to the rooms. How can this be done? I've tried: - ... to search for an injection point in the Hubs server running in AWS, but cannot find it (how the room web page is created and from which templates, and where the templates are?) - ... to deploy our custom Hubs server using "npm run deploy", but the server gets broken and cannot load rooms any more... Ideally I'd just mod an existing server without deploying it again as the customer might not allow redeploying... PS. We cannot create a browser plugin as the customer uses Oculus Quests to run Hubs, and on Quest you cannot use your own browser plugins... Thanks!

All Replies (5)

more options

Hi there! support.mozilla.com is better suited for more general questions about Mozilla Hubs, due to the technical nature of this question (it relates to Hubs Cloud), it would be better suited for our Github Discussions page.

Have you taken a look to see if there is any relevant information there?

To briefly answer your question, there is no way to inject javascript into hubs.mozilla.com, however, you can create a custom client using Hubs Cloud and add the code in there. We don't really have a good spot to throw your own JS in, but you might try the place that John suggests in this response:

https://github.com/mozilla/hubs/discussions/2826

There are a few issues in discussions that related to npm run deploy, here are the search results for npm in discussions https://github.com/mozilla/hubs/discussions?discussions_q=npm - perhaps one of these might address your issue,, and if not, I would check what version of node you are using, and if it's up to date, create a new discussion thread with more information about any errors you might see when you try accessing your page.

more options

Hi!

Sorry for not being clear about the issue, I was just wondering if I could somehow add javascript to a running, existing custom instance of Hubs running on AWS. I don't want to mod hubs.mozilla.com, but our own instance of Hubs... Or the customer's instance in this case.

Perhaps we'll need to get "npm run deploy" to work, somehow. We tried it with a two weeks old AWS Hubs server, but didn't work. I reinstalled it yesterday, will try again later today after we tell the customer about our "progress"... :)

more options

Did you take a look at the file john suggested modifying here: https://github.com/mozilla/hubs/discussions/2826

He recommends a place where you could throw some code in to run every frame in a custom instance of Hubs. "We do not have guides/documentation for modifying the client, and it'll depend on what you're trying to do, but if you are just looking for somewhere to run some javascript every frame, one option is to put it in hubs-systems: https://github.com/mozilla/hubs/blob/master/src/systems/hubs-systems.js (Or you could wrap your code in your own aframe components/systems)"

If you continue having trouble today, it would be great if you could create a thread about with more information on the error in our Github discussions - https://github.com/mozilla/hubs/discussions - this is where we can answer more technical questions about Hubs Cloud

more options

Hi!

I cannot find that hubs-systems.js anywhere on S3 or EC2 so I cannot mod our live server. If we could deploy our custom Hubs client/server we could do that, but currently it's not working for us.

Is there a reason why inline script execution is prohibited on the html pages? If it was enabled we could mod the html's on S3 and solve our problem...

I posted a bug report/question about this to GitHub...

more options

Thanks! I'm afraid I can't speak to this level of technical details but hopefully my team has more information. I transferred your question to the discussions sections (from the bug report section) as this is where our team looks for questions: https://github.com/mozilla/hubs/discussions/3601