Skip to content

Instantly share code, notes, and snippets.

@rothgar
Last active December 3, 2021 16:40
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save rothgar/92e69d5bdcf80ea23f065bb6db03f7cd to your computer and use it in GitHub Desktop.
Save rothgar/92e69d5bdcf80ea23f065bb6db03f7cd to your computer and use it in GitHub Desktop.
Streamyard Keyboard Shortcuts
// ==UserScript==
// @name Streamyard Keyboard Shortcuts
// @namespace http://streamyard.com
// @version 0.1
// @description Simple keyboard shortcuts for streamyard
// @author justinleegarrison@gmail.com
// @match https://streamyard.com/*
// @grant none
// @run-at document-end
// ==/UserScript==
(function() {
'use strict';
document.addEventListener('keydown', function(e) {
//console.log(e);
if (e.key == "m" && !e.shiftKey && !e.ctrlKey && !e.altKey && !e.metaKey) {
var unmuteButton = document.querySelector('[aria-label="Unmute microphone"]');
var muteButton = document.querySelector('[aria-label="Mute microphone"]');
if (unmuteButton !== null) {
unmuteButton.click();
} else {
muteButton.click();
}
} else if (e.key == "v" && !e.shiftKey && !e.ctrlKey && !e.altKey && !e.metaKey) {
var faceUnmuteButton = document.querySelector('[aria-label="turn on camera"]');
var faceMuteButton = document.querySelector('[aria-label="turn off camera"]');
if (faceUnmuteButton !== null) {
faceUnmuteButton.click();
} else {
faceMuteButton.click();
}
}
}, false);
})();
@cesarhernandezgt
Copy link

cesarhernandezgt commented Sep 23, 2020

Hi @rothgar is this a script you can add to a live Streamyard session?
If yes, I tried to add it editing vie google chrome developer tools and adding in the <head> section something like:

<script type="text/javascript" async="" src="https://gist.githubusercontent.com/rothgar/92e69d5bdcf80ea23f065bb6db03f7cd/raw/8b1d8e1288be068c3a4aecbcc6e1bdbc3862da68/streamyard-tampermonkey.js"></script>

But after typing m the mute action didn't trigger. any clue on what's went wrong?

@rothgar
Copy link
Author

rothgar commented Sep 23, 2020

I'm loading the script with tampermonkey https://chrome.google.com/webstore/detail/tampermonkey/dhdgffkkebhmkfjojejmpbldmpobfkfo

It works but has some bugs I haven't had time to fix yet. Would welcome any feedback/updates to make it more stable.

Specifically I need to detect when the keyboard isn't focused on an input field (chat window)

@cathellis
Copy link

I'm interested in this, can I make it work with my Elgato Stream Deck?

@timmmmyboy
Copy link

I'm interested in this, can I make it work with my Elgato Stream Deck?

I was able to use a Stream Deck with this no problem, simply simulate the keyboard presses in the software and have Streamyard open with this script and it works. I was also able to modify this to simulate a few other shots like the various layouts since they all had unique aria text. Thanks @rothgar!

@YG0613
Copy link

YG0613 commented Dec 3, 2021

Could scripts like these be used with Tampermonkey to execute cusotm multi-action macros in Streamyard?

For example, I would love to be able to program a key on the Elgato Stream Deck to put a png or GIF overlay onto the stream for a specified amount of time and then take it down, for example Like or Subscribe images or animations for 3-5 seconds.

If yes, and someone would be interested in putting some code together (for remuneration) please reach out [yisroel @ rabbiglick.com].

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment