jaw-sh / stream-nexus

Unified multicast stream chat overlay.
26 stars 7 forks source link

Connect to chats directly #9

Closed c915 closed 10 months ago

c915 commented 1 year ago

Apparently it's possible and not too difficult to connect directly to stream chats. Not sure if this is something you would be interested in doing, but I figured I'd share it at least.

Odysee and Kick uses websockets, where Kick requires you to send a subscription message with a chatroom id, Odysee just lets you read directly. Rumble uses a stream you can read directly from. Haven't looked at VK yet.

Example code: https://gist.github.com/c915/562868ee5cb813db53087119c544ef41

Thanks for the awesome streams.

y-a-t-s commented 1 year ago

I like this a lot, especially from a future-proofing standpoint. I remember when I was messing around with Kick support, I noticed that the badges which have obfuscated naming in the HTML were named properly in the chat JSON. And it probably cuts down on latency by a hair. So this definitely has quite a few benefits.

Plus, intercepting requests is super easy to do with a browser extension, which is something I'm working on to replace userscripts.

jaw-sh commented 1 year ago

I'm going to try and rewrite the reorganize all the frontend code to use EC6 classes, webpack to publish a single Userscript that works on all supported domains, and a way to DOM observe or Websocket observe. You're right, that's how it should be done.

I would also like to add a localhost page for viewing all observed donations, and a way to display viewers.

c915 commented 1 year ago

Small update for Rumble, chat there uses Server Sent Events, so it's probably better to use a crate that handles that, like reqwest-eventsource rather than read directly from the stream as I did.

y-a-t-s commented 10 months ago

I had the idea that instead of reinventing the wheel, we can simply hook the sites' existing JS to make and handle the connections.

acfd91e has a quick proof of concept for Rumble that just logs each received JSON object to the console for now. It relies on the chatroom ID being present in the url for the popout chat for simplicity's sake, but it shouldn't be hard to get it other ways.

jaw-sh commented 10 months ago

47e3e3c14371c0a14f0735f04a2c7b21cd5f1cd3

This is an unbelievable pain in the ass (a lot harder than just DOM observations, surprisingly) but it's making progress.

There's a very frustrating level of complexity with each website, and X is not doable without CSP modifications.