matrix-widget-api icon indicating copy to clipboard operation
matrix-widget-api copied to clipboard

[HELP] How to make a custom widget that receives a matrix user's userid?

Open 153 opened this issue 3 years ago • 1 comments

Let's say my friend hosts a hypothetical video game that allows users to join without registration, and a URL like https://coolgame.com/?guestname= allows the browser to suggest a pre-filled username (similar to KiwiIRC, some wikis, Jitsi, etherpad, etc). When I simply add $matrix_user_id to the end of the URL (e.g. /addwidget https://coolgame.com/?guestname=$matrix_user_id ) the game website thinks that a guest wants to use the name $matrix_user_id, instead of alice, bob etc

If I host a file, e.g. https://mysite.com/coolgame.html, can I simply use <script src="https://unpkg.com/[email protected]/dist/api.min.js"></script> + <iframe src="https://coolgame.com/?guestname=$matrix_user_id"></iframe>

then in Element enter /addwidget https://mysite.com/coolgame.html to allow my Matrix users to open the game widget with their name pre-filled for them?

I tried to ask about this kind of scenario in the Matrix room and am still a bit lost. I think that asking this as an issue is useful, because if other people wonder how to do this hypothetical scenario in the future (it will become more common as Matrix and Element, etc grow) this issue / future documentation should be able to cover this hypothetical usecase: help someone who's not a webdev or JS person make a custom widget that listens to Matrix suggestions (eg: room name, username) with as little work as possible.

Sorry to be a nuisance, and I am very grateful for any support 🙏

153 avatar Nov 04 '21 16:11 153