FRESH GREETZ
Made by "AromaPunk", with Love and Peace and OVERunity
here the script again:
// ==UserScript==
// @name OBS Pause Handler
// @namespace
http://tampermonkey.net/
// @version 0.1
// @description Handle OBS Pause Events
// @match *://*/* // Set this to the correct URL of the webpage
// @grant none
// @author (C) AromaPunk 2024 - OSTTIROL
// ==/UserScript==
//
// █████╗ ██████╗ ██████╗ ███╗ ███╗ █████╗ ██████╗ ██╗ ██╗███╗ ██╗██╗ ██╗
// ██╔══██╗██╔══██╗██╔═══██╗████╗ ████║██╔══██╗██╔══██╗██║ ██║████╗ ██║██║ ██╔╝
// ███████║██████╔╝██║ ██║██╔████╔██║███████║██████╔╝██║ ██║██╔██╗ ██║█████╔╝
// ██╔══██║██╔══██╗██║ ██║██║╚██╔╝██║██╔══██║██╔═══╝ ██║ ██║██║╚██╗██║██╔═██╗
// ██║ ██║██║ ██║╚██████╔╝██║ ╚═╝ ██║██║ ██║██║ ╚██████╔╝██║ ╚████║██║ ██╗
// ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═════╝ ╚═╝ ╚═══╝╚═╝ ╚═╝
(function() {
'use strict';
// Hier den WebSocket-Code einfügen
// WebSocket URL to connect to OBS WebSocket plugin
const OBS_WEBSOCKET_URL = "ws://localhost:4444"; // Default URL, change if necessary
const OBS_WEBSOCKET_PASSWORD = ""; // Add password if needed
// Create a WebSocket connection to OBS
const socket = new WebSocket(OBS_WEBSOCKET_URL);
// Function to authenticate to OBS WebSocket if a password is required
socket.onopen = function () {
console.log("Connected to OBS WebSocket");
// If OBS WebSocket has a password, you need to authenticate
if (OBS_WEBSOCKET_PASSWORD) {
const authMessage = {
"op": 1,
"d": {
"rpcVersion": 1,
"authentication": OBS_WEBSOCKET_PASSWORD
}
};
socket.send(JSON.stringify(authMessage));
}
};
// Event listener for messages from OBS WebSocket
socket.onmessage = function (event) {
const message = JSON.parse(event.data);
// Check for the event type
if (message.op === 0 && message.d.eventType === "StreamStateChanged") {
const streamState = message.d.eventData.outputState;
if (streamState === "OBS_WEBSOCKET_OUTPUT_PAUSED") {
console.log("OBS recording paused, stopping browser stream...");
stopBrowserStream();
}
if (streamState === "OBS_WEBSOCKET_OUTPUT_RESUMED") {
console.log("OBS recording resumed, starting browser stream...");
startBrowserStream();
}
}
};
// Event handler for WebSocket errors
socket.onerror = function (error) {
console.error("WebSocket error:", error);
};
// Close the WebSocket connection cleanly
socket.onclose = function () {
console.log("WebSocket connection closed.");
};
// Function to stop the stream or perform an action in the browser
function stopBrowserStream() {
// Implement logic to stop your stream here
console.log("Stopping the stream...");
// Example: pause a video element
const video = document.querySelector("video");
if (video) {
video.pause();
}
}
// Function to start the stream or perform an action in the browser
function startBrowserStream() {
// Implement logic to start your stream here
console.log("Starting the stream...");
// Example: play a video element
const video = document.querySelector("video");
if (video) {
video.play();
}
}
})();