Skip to content

Instantly share code, notes, and snippets.

@Utopiah
Created February 20, 2022 11:16
Show Gist options
  • Save Utopiah/b076c63afe4fb84322089c4f42d4c4ce to your computer and use it in GitHub Desktop.
Save Utopiah/b076c63afe4fb84322089c4f42d4c4ce to your computer and use it in GitHub Desktop.
// to run on e.g hubs.mozilla.com in a room
fetch('/cloud').then(function (response) {
// limited due to CSP
return response.text();
}).then(function (html) {
var parser = new DOMParser();
var doc = parser.parseFromString(html, 'text/html');
var desc = doc.head.querySelector('meta[property="og:description"]').content;
var el = document.createElement("a-entity");
el.setAttribute("text","value", desc);
// ToDo : find the right template or extends Hubs NAF schemas for text.
el.setAttribute("position", "0 2 0");
AFRAME.scenes[0].appendChild(el);
// not networked for now, so limited to 1 person!
// for static text this is "solved" by being directly in the room code
// thus shared to all participants.
}).catch(function (err) {
console.warn('Fetch error:', err);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment