Skip to content

Instantly share code, notes, and snippets.

@thebirk
Created February 5, 2024 23:56
Show Gist options
  • Save thebirk/39d0c65cddeb45382145086962561cb2 to your computer and use it in GitHub Desktop.
Save thebirk/39d0c65cddeb45382145086962561cb2 to your computer and use it in GitHub Desktop.
OBS Websocket browser proof of concept
document.addEventListener("contextmenu", async function(e) {
const message = e.target.closest('.chat-line__message');
if (!message) {
return;
}
e.preventDefault();
const obs = new OBSWebSocket();
await obs.connect("ws://127.0.0.1:4455", "4tP1Yw7d5FxnnCjI");
await obs.call("SetInputSettings", {
inputName: "ChatHighlight",
overlay: true,
inputSettings: {
url: "data:text/html,<style>html,body{background:white;}</style>" + message.innerHTML,
},
});
await obs.disconnect();
})
{
"name": "OBS Chat Highlight",
"description": "Pin a message to a OBS browser source",
"version": "1.0",
"manifest_version": 3,
"content_scripts": [
{ "matches": ["*://*.twitch.tv/*"], "js": ["obs-ws.min.js", "content.js"] }
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment